using System.Linq;
using BO.AppServer.Data.Entity;
using Quadarax.Foundation.Core.Data;
using Quadarax.Foundation.Core.Data.Domain;
using Quadarax.Foundation.Core.Data.Interface.Domain;
using Quadarax.Foundation.Core.Data.Repository;

public class MetadocumentRepo : EntityRepository<long,  Metadocument>
    {
        public MetadocumentRepo(IUnitOfWork<DataDomain> unitOfWork) : base(unitOfWork)
        {
            DefaultIncludes.Add("Artifacts");
        }


        public Metadocument Get(long workspaceId, long metadocumentId)
        {
            var document = Get(metadocumentId);
            if (document == null)
                return null;
            if (document.Structure.WorkspaceId != workspaceId)
                return null;
            return document;

        }
        public Metadocument GetByName(long workspaceId, string name)
        {
            return Query(new Paging()).FirstOrDefault(x => x.Structure.WorkspaceId == workspaceId && x.Name .ToLower()== name.ToLower());

        }

    }