public static IEnumerable <Product> MostExpensiveProductByCategory(this IRepositoryBaseAsync <Category> repository, int id) { return(repository.ProductByCategory(id) .OrderByDescending(b => b.Price) .Take(5) .AsEnumerable()); }
public static void UnassignOfferFromGroup(this IRepositoryBaseAsync <CollocationGroup> repo, string idMem, int idGroup) { DatabaseFactory dbf = new DatabaseFactory(); User emp = dbf.DataContext.Users.FirstOrDefault(x => x.Id == idMem); dbf.DataContext.CollocationGroups.Include("User").FirstOrDefault(x => x.CollocationGroupId == idGroup).users.Remove(emp); dbf.DataContext.SaveChanges(); }
public static int AddOfferWithGetingId(this IRepositoryBaseAsync <CollocationGroup> repo, CollocationGroup t) { DatabaseFactory dbf = new DatabaseFactory(); dbf.DataContext.CollocationGroups.Add(t); dbf.DataContext.SaveChanges(); int id = t.CollocationGroupId; return(id); }
public static void AssignNewsToAdmin(this IRepositoryBaseAsync <news> repo, int idAdmin, int idTopic) { idAdmin = id_admin; idTopic = id_topic; DatabaseFactory dbf = new DatabaseFactory(); member admin = dbf.DataContext.members.FirstOrDefault(x => x.id_Member == idAdmin); topic topics = dbf.DataContext.topics.FirstOrDefault(x => x.idTopic == idTopic); //news n = dbf.DataContext.news.FirstOrDefault(x => x.idNews == id_news); news n = new news(); n.member.news.Add(n); n.topic.news.Add(n); dbf.DataContext.news.Add(n); //dbf.DataContext.news.Include("members").FirstOrDefault(x => x.idNews == id_news); // news n = dbf.DataContext.news.FirstOrDefault(x => x.idNews == id_news); //dbf.DataContext.members.Include("news").FirstOrDefault(x => x.id_Member == idAdmin).news.Add(n); // User emp = dbf.DataContext.Users.FirstOrDefault(x => x.Id == idMem); //dbf.DataContext.CollocationGroups.Include("users").FirstOrDefault(x => x.CollocationGroupId == idGroup).users.Add(emp); dbf.DataContext.SaveChanges(); }
public static IEnumerable <Product> ProductByCategory(this IRepositoryBaseAsync <Category> repository, int id) { return(repository.GetById(id).Products.AsEnumerable()); }
public BaseAsyncService(IRepositoryBaseAsync <T> repository, IUnitOfWorkAsync unitOfWork) { this._repository = repository; this._unitOfWork = unitOfWork; }
public BaseAsyncService(IRepositoryBaseAsync <T> repository) { _repository = repository; }
public ServiceBase(IRepositoryBaseAsync <TEntity> repository) { this.repository = repository; }