//Updates the existing Insurance Type Details public async Task <IActionResult> OnPutUpdateInsuranceType([FromBody] Models.ActCostInsuranceType obj) { if (obj != null && (HttpContext.User.IsInRole("Admin"))) { try { //Set the split to be per SILO obj.ActCostInsuranceTypeID = 12; _context.Attach(obj).State = EntityState.Modified; await _context.SaveChangesAsync(); return(new JsonResult(obj)); } catch (DbUpdateException d) { return(new JsonResult("Insurance Type not saved." + d.InnerException.Message)); } } return(new JsonResult("Insurance Type not saved saved.")); }
//Inserts a new Insurance Type public async Task <IActionResult> OnPostInsertInsuranceType([FromBody] Models.ActCostInsuranceType obj) { if (obj != null && (HttpContext.User.IsInRole("Admin") || HttpContext.User.IsInRole("Fleet"))) { try { _context.Add(obj); await _context.SaveChangesAsync(); int id = obj.ActCostInsuranceTypeID; // Yes it's here return(new JsonResult(obj)); } catch (DbUpdateException d) { return(new JsonResult("Act Cost Insurance Not Added." + d.InnerException.Message)); } } else { return(new JsonResult("Act Cost Insurance Not Inserted")); } }