コード例 #1
0
 public void CreateUnit(UnitModel unitModel)
 {
     using (var db = new DBNikoletaContext())
     {
         db.Units.Add(unitModel);
         db.SaveChanges();
     }
 }
コード例 #2
0
 public void AddProduct(ProductModel product)
 {
     using (var db = new DBNikoletaContext())
     {
         db.Products.Add(product);
         db.SaveChanges();
     }
 }
コード例 #3
0
 public List<UnitModel> GetAllUnits()
 {
     List<UnitModel> result = new List<UnitModel>();
     using (var db = new DBNikoletaContext())
     {
         result = db.Units.ToList();
     }
     return result;
 }
コード例 #4
0
 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();
     }
 }
コード例 #5
0
 public UnitModel GetUnit(string code)
 {
     UnitModel unit;
     using (var db = new DBNikoletaContext())
     {
         unit = db.Units.FirstOrDefault(u => u.Code == code);
     }
     return unit;
 }
コード例 #6
0
        public void SetCoeficientPrice(decimal coeficient)
        {
            using (var db = new DBNikoletaContext())
            {
                SettingModel setting = db.Settings.FirstOrDefault();
                setting.CoeficientPrice = coeficient;

                db.SaveChanges();
            }
        }
コード例 #7
0
        public decimal GetCoeficientPrice()
        {
            decimal coeficient = 0;
            using (var db = new DBNikoletaContext())
            {
                SettingModel setting = db.Settings.FirstOrDefault();
                coeficient = setting.CoeficientPrice;
            }
            return coeficient;

        }
コード例 #8
0
 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();
     }
 }