public static bool Update(VarianViewModel model) { bool result = true; try { using (var db = new VapeContext()) { if (model.Id == 0) { Mst_Varian var = new Mst_Varian(); var.VarianCode = model.VarianCode; var.VarianName = model.VarianName; var.ItemCode = model.ItemCode; var.Country = model.Country; var.Strength = model.Strength; var.PGVG = model.PGVG; var.Size = model.Size; var.Price = model.Price; var.Unit = model.Unit; var.IsActive = model.IsActive; db.Mst_Varian.Add(var); db.SaveChanges(); } else { Mst_Varian var = db.Mst_Varian.Where(o => o.Id == model.Id).FirstOrDefault(); if (var != null) { var.VarianCode = model.VarianCode; var.VarianName = model.VarianName; var.ItemCode = model.ItemCode; var.Country = model.Country; var.Strength = model.Strength; var.PGVG = model.PGVG; var.Size = model.Size; var.Price = model.Price; var.Unit = model.Unit; var.IsActive = model.IsActive; db.SaveChanges(); } } } } catch (Exception ex) { Message = ex.Message; result = false; } return(result); }
public static bool Update(ItemViewModel model) { bool result = true; try { using (var db = new VapeContext()) { if (model.Id == 0) { Mst_Item ite = new Mst_Item(); ite.ItemCode = model.ItemCode; ite.ItemName = model.ItemName; ite.CategoryCode = model.CategoryCode; ite.Description = model.Description; ite.Stock = ite.Stock; ite.IsActive = model.IsActive; db.Mst_Item.Add(ite); db.SaveChanges(); } else { Mst_Item ite = db.Mst_Item.Where(o => o.Id == model.Id).FirstOrDefault(); if (ite != null) { ite.ItemCode = model.ItemCode; ite.ItemName = model.ItemName; ite.CategoryCode = model.CategoryCode; ite.Description = ite.Description; ite.Stock = ite.Stock; ite.IsActive = model.IsActive; db.SaveChanges(); } } } } catch (Exception ex) { Message = ex.Message; result = false; } return(result); }
public static bool Update(CustomerViewModel model) { bool result = true; try { using (var db = new VapeContext()) { if (model.Id == 0) { Mst_Customer cus = new Mst_Customer(); cus.CostumerName = model.CostumerName; cus.Address = model.Address; cus.Email = model.Email; cus.Phone = model.Phone; cus.IsActive = model.IsActive; db.Mst_Customer.Add(cus); db.SaveChanges(); } else { Mst_Customer cus = db.Mst_Customer.Where(o => o.Id == model.Id).FirstOrDefault(); if (cus != null) { cus.CostumerName = model.CostumerName; cus.Address = model.Address; cus.Email = model.Email; cus.Phone = model.Phone; cus.IsActive = model.IsActive; db.SaveChanges(); } } } } catch (Exception ex) { Message = ex.Message; result = false; } return(result); }
public static bool Update(SupplierViewModel model) { bool result = true; try { using (var db = new VapeContext()) { if (model.Id == 0) { Mst_Supplier sup = new Mst_Supplier(); sup.SupplierCode = model.SupplierCode; sup.SupplierName = model.SupplierName; sup.Address = model.Address; sup.Phone = model.Phone; sup.IsActive = model.IsActive; db.Mst_Supplier.Add(sup); db.SaveChanges(); } else { Mst_Supplier sup = db.Mst_Supplier.Where(o => o.Id == model.Id).FirstOrDefault(); if (sup != null) { sup.SupplierCode = model.SupplierCode; sup.SupplierName = model.SupplierName; sup.Address = model.Address; sup.Phone = model.Phone; sup.IsActive = model.IsActive; db.SaveChanges(); } } } } catch (Exception ex) { Message = ex.Message; result = false; } return(result); }
public static bool Update(CategoryViewModel model) { bool result = true; try { using (var db = new VapeContext()) { if (model.Id == 0) { Mst_Category cat = new Mst_Category(); cat.CategoryCode = model.CategoryCode; cat.CategoryName = model.CategoryName; cat.IsActive = model.IsActive; db.Mst_Category.Add(cat); db.SaveChanges(); } else { Mst_Category cat = db.Mst_Category.Where(o => o.Id == model.Id).FirstOrDefault(); if (cat != null) { cat.CategoryCode = model.CategoryCode; cat.CategoryName = model.CategoryName; cat.IsActive = model.IsActive; db.SaveChanges(); } } } } catch (Exception ex) { Message = ex.Message; result = false; } return(result); }
public static bool Delete(int id) { bool result = true; try { using (var db = new VapeContext()) { Mst_Category cat = db.Mst_Category.Where(o => o.Id == id).FirstOrDefault(); if (cat != null) { db.Mst_Category.Remove(cat); db.SaveChanges(); } } } catch (Exception ex) { Message = ex.Message; result = false; } return(result); }
public void Update(FullVape fullVape) { db.Entry(fullVape).State = EntityState.Modified; db.SaveChanges(); }
public void Save() { db.SaveChanges(); }