public async Task <int> insert(sys_warehouse_position_model model) { await _context.sys_warehouse_positions.AddAsync(model.db); _context.SaveChanges(); return(1); }
public int update(sys_warehouse_position_model model) { var db = _context.sys_warehouse_positions.Where(d => d.id == model.db.id).FirstOrDefault(); db.name = model.db.name; db.status_del = model.db.status_del; db.note = model.db.note; db.col = model.db.col; db.row = model.db.row; db.id_warehouse = model.db.id_warehouse; db.update_by = model.db.update_by; db.update_date = model.db.update_date; _context.SaveChanges(); return(1); }
private bool checkModelStateCreateEdit(ActionEnumForm action, sys_warehouse_position_model item) { if (string.IsNullOrEmpty(item.db.id_warehouse)) { ModelState.AddModelError("db.id_warehouse", "required"); } if (string.IsNullOrEmpty(item.db.name)) { ModelState.AddModelError("db.name", "required"); } if (item.db.row == null) { ModelState.AddModelError("db.row", "required"); } if (item.db.col == null) { ModelState.AddModelError("db.col", "required"); } var searchName = repo.FindAll().Where(d => d.db.id_warehouse == item.db.id_warehouse && d.db.name == item.db.name && d.db.id != item.db.id).Count(); if (searchName > 0) { ModelState.AddModelError("db.name", "existed"); } var searchrowcol = repo.FindAll().Where(d => d.db.id_warehouse == item.db.id_warehouse && d.db.col == item.db.col && d.db.row == item.db.row && d.db.id != item.db.id ).Count(); if (searchrowcol > 0) { ModelState.AddModelError("db.col", "existed"); ModelState.AddModelError("db.row", "existed"); } return(ModelState.IsValid); }
private bool checkModelStateEdit(sys_warehouse_position_model item) { return(checkModelStateCreateEdit(ActionEnumForm.edit, item)); }