//Updates the existing Account Details public async Task <IActionResult> OnPutUpdateWarehouse([FromBody] Models.ActCostWarehouse obj) { if (obj != null && (HttpContext.User.IsInRole("Admin"))) { try { _context.Attach(obj).State = EntityState.Modified; await _context.SaveChangesAsync(); return(new JsonResult(obj)); } catch (DbUpdateException d) { return(new JsonResult("Warehouse Changes not saved." + d.InnerException.Message)); } } return(new JsonResult("Warehouses Changes not saved.")); }
//Inserts a new Account with details public async Task <IActionResult> OnPostInsertWarehouse([FromBody] Models.ActCostWarehouse obj) { if (obj != null && (HttpContext.User.IsInRole("Admin"))) { try { _context.Add(obj); await _context.SaveChangesAsync(); int id = obj.ActCostWarehouseID; // Yes it's here return(new JsonResult(obj)); } catch (DbUpdateException d) { return(new JsonResult("Warehouse Not Added." + d.InnerException.Message)); } } else { return(new JsonResult("Warehouse Not Inserted")); } }