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); } }