public IActionResult Update([FromBody] ItemMasterUnit itemMasterUnit) { try { ItemMasterUnit itemMu = dbContext.itemMasterUnits.Find(itemMasterUnit.ID, itemMasterUnit.itemMasterUnitUnit); if (itemMu != null) { itemMu.itemMasterUnitUnit = itemMasterUnit.itemMasterUnitUnit; itemMu.itemMasterUnitConversion = itemMasterUnit.itemMasterUnitConversion; // dbContext.ItemMasters.Update(itemMaster); dbContext.SaveChanges(); return(Ok(itemMu)); } else { throw new Exception($"User Not found with a user ID of '{itemMu.ID}'."); } } catch (Exception ex) { return(BadRequest(GetErrorMessage(ex))); } }
public IActionResult Add([FromBody] ItemMasterUnit itemMasterUnit) { try { dbContext.itemMasterUnits.Add(itemMasterUnit); dbContext.SaveChanges(); return(Ok(itemMasterUnit)); } catch (Exception ex) { return(BadRequest(GetErrorMessage(ex))); } }
public IActionResult Delete(string id, string unit) { try { ItemMasterUnit itemMu = dbContext.itemMasterUnits.Find(id, unit); if (itemMu != null) { dbContext.itemMasterUnits.Remove(itemMu); dbContext.SaveChanges(); return(Json(id)); } else { throw new Exception($"User Not found with a user ID of '{id}'."); } } catch (Exception ex) { return(BadRequest(GetErrorMessage(ex))); } }