using System.Collections.Generic;
using System.Linq;
using Bivi.Domaine;

namespace Bivi.Data.Depots
{
    public partial class DepotModule
    {
        public IQueryable<Module> GetAll()
        {
            var modules = from d in DbContext.Modules
                                  select d;
            return modules;
        }

        public IQueryable<Module> GetByRights(IEnumerable<DroitDto> droits)
        {
            long[] droitsID = droits.Select(x => x.ID).ToArray();

            var query = from l in DbContext.Lien_Droit_Modules
                        join m in DbContext.Modules on l.Module.ID equals m.ID
                        where droitsID.Contains(l.Droit.ID)
                        select m;

            return query;
        }
    }
 }
