public List <Model.Dokument> Get(DokumentSearchRequest search) { var q = _context.Set <Database.Dokument>().AsQueryable(); if (!string.IsNullOrEmpty(search?.Naziv)) { q = q.Where(x => x.NazivDokumenta.ToLower().StartsWith(search.Naziv) || x.NazivDokumenta.ToUpper().StartsWith(search.Naziv)); } q = q.OrderBy(x => x.NazivDokumenta); var list = q.ToList(); return(_mapper.Map <List <Model.Dokument> >(list)); }
public bool AddPlating(PlatingAddList model) { using (var context = new CookbookContext()) { var entities = context.RecipePlatings.Where(e => e.RecipeID == model.RecipeId); foreach (var entity in entities) { context.RecipePlatings.Remove(entity); } foreach (var plating in model.Platings) { if (plating.IsIncluded == true) { context.Set <RecipePlating>().Add(new RecipePlating { PlatingID = plating.ID, RecipeID = model.RecipeId }); } } return(context.SaveChanges() != -1); } }
public virtual List <TModel> Get(TSearch search) { var list = _context.Set <TDatabase>().ToList(); return(_mapper.Map <List <TModel> >(list)); }