public void CreateUnit(UnitModel unitModel) { using (var db = new DBNikoletaContext()) { db.Units.Add(unitModel); db.SaveChanges(); } }
public void AddProduct(ProductModel product) { using (var db = new DBNikoletaContext()) { db.Products.Add(product); db.SaveChanges(); } }
public List<UnitModel> GetAllUnits() { List<UnitModel> result = new List<UnitModel>(); using (var db = new DBNikoletaContext()) { result = db.Units.ToList(); } return result; }
public void DeleteUnit(string code) { using (var db = new DBNikoletaContext()) { UnitModel unit = db.Units.FirstOrDefault(u => u.Code == code); db.Units.Remove(unit); db.SaveChanges(); } }
public UnitModel GetUnit(string code) { UnitModel unit; using (var db = new DBNikoletaContext()) { unit = db.Units.FirstOrDefault(u => u.Code == code); } return unit; }
public void SetCoeficientPrice(decimal coeficient) { using (var db = new DBNikoletaContext()) { SettingModel setting = db.Settings.FirstOrDefault(); setting.CoeficientPrice = coeficient; db.SaveChanges(); } }
public decimal GetCoeficientPrice() { decimal coeficient = 0; using (var db = new DBNikoletaContext()) { SettingModel setting = db.Settings.FirstOrDefault(); coeficient = setting.CoeficientPrice; } return coeficient; }
public void UpdateUnit(string newDescription, UnitModel unitToUpdate) { using (var db = new DBNikoletaContext()) { UnitModel unit = db.Units.FirstOrDefault(u => u.Code == unitToUpdate.Code); unit.Description = newDescription; db.SaveChanges(); } }