public IActionResult UpdateLoaiId(int id, LoaiModel model) { var loai = _context.Loais.SingleOrDefault(lo => lo.MaLoai == id); if (loai != null) { loai.TenLoai = model.TenLoai; _context.SaveChanges(); return(Ok(loai)); } else { return(NotFound()); } }
public IActionResult CreateNew(LoaiModel model) { try { var loai = new Loai { TenLoai = model.TenLoai }; _context.Add(loai); _context.SaveChanges(); return(Ok(loai)); }catch { return(BadRequest()); } }
public bool Update(LoaiModel model) { string msgError = ""; try { var result = _dbHelper.ExecuteScalarSProcedureWithTransaction(out msgError, "sp_loai_update", "@maloai", model.ma_loai, "@tenloai", model.ten_loai); if ((result != null && !string.IsNullOrEmpty(result.ToString())) || !string.IsNullOrEmpty(msgError)) { throw new Exception(Convert.ToString(result) + msgError); } return(true); } catch (Exception ex) { throw ex; } }
public bool Create(LoaiModel model) { return(_res.Create(model)); }
public bool Update(LoaiModel model) { return(_res.Update(model)); }
public LoaiModel UpdateLoai([FromBody] LoaiModel model) { _itemBusiness.Update(model); return(model); }
public LoaiModel CreateLoai([FromBody] LoaiModel model) { model.ma_loai = Guid.NewGuid().ToString(); _itemBusiness.Create(model); return(model); }
public LoaiModel CreateItem([FromBody] LoaiModel model) { _itemBusiness.Create(model); return(model); }