public IEnumerable <Grocery> GetOrderedList(string filter) { if (filter.Contains("Category")) { filter = filter.Replace("Category", "Category.Name"); } dao = new GroceryDao(); return(dao.GetAll().OrderBy(filter)); }
public void SetModel() { dao = new GroceryDao(); Grocery g = dao.GetById(Id); this.Id = g.Id; this.Name = g.Name; this.Price = g.Price; this.CategoryId = g.CategoryId; this.Unit = g.Unit; this.InBasket = g.InBasket; this.Category = Category.GetCategories().First(x => x.Id == this.CategoryId); }
public void AddOrUpdate() { dao = new GroceryDao(); if (dao.GetById(Id) == null) { dao.Insert(this); } else { dao.Update(this); } }
public void Remove() { dao = new GroceryDao(); dao.Remove(Id); }
public IEnumerable <Grocery> GetAllInBasket() { dao = new GroceryDao(); return(dao.GetAll().Where(x => x.InBasket)); }
public IEnumerable <Grocery> GetAll() { dao = new GroceryDao(); return(dao.GetAll()); }