private bool checkModelStateCreateEdit(ActionEnumForm action, production_order_need_supplier_master_model item) { if (item.list_need_supplier.Count == 0) { ModelState.AddModelError("list_need_supplier", "required"); } return(ModelState.IsValid); }
public int update(production_order_need_supplier_master_model model) { var db = _context.production_order_items.Where(d => d.id == model.db.id).FirstOrDefault(); db.id_item_bom_config = model.db.id_item_bom_config; db.status_bom = 2; _context.SaveChanges(); saveDetailProvide(model); return(1); }
public void saveDetailProvide(production_order_need_supplier_master_model model) { var delete = _context.production_order_need_suppliers.Where(t => t.id_production_order_item == model.db.id); _context.RemoveRange(delete); _context.SaveChanges(); var production_item = _context.production_order_items.Where(t => t.id == model.db.id).SingleOrDefault(); model.list_need_supplier.ForEach(t => { t.db.id = 0; t.db.quantity = t.db.quota * production_item.quantity; t.db.quantity_unit_main = t.db.quota_main * production_item.quantity; }); var listInsert = model.list_need_supplier.Select(d => d.db).ToList(); _context.production_order_need_suppliers.AddRange(listInsert); _context.SaveChanges(); }
private bool checkModelStateEdit(production_order_need_supplier_master_model item) { return(checkModelStateCreateEdit(ActionEnumForm.edit, item)); }