public async Task <IActionResult> PostNewEmploymentStatus([FromBody] PostNewEmploymentStatus postNewEmploymentStatus) { if (postNewEmploymentStatus == null) { return(Json(new { msg = "No Data" } )); } var orgId = getOrg(); var organisationDetails = await _context.Organisations.Where(x => x.Id == orgId).FirstOrDefaultAsync(); int noOfEmployee = _context.Users.Where(x => x.OrganisationId == orgId).Count(); try { EmploymentStatus newEmploymentStatus = new EmploymentStatus() { Id = Guid.NewGuid(), EmploymentStatusName = postNewEmploymentStatus.EmploymentStatusName, Description = postNewEmploymentStatus.Description, OrganisationId = orgId }; _context.Add(newEmploymentStatus); _context.SaveChanges(); return(Json(new { msg = "Success" } )); } catch (Exception ee) { } return(Json( new { msg = "Fail" })); }
public async Task <IActionResult> editEmploymentStatus([FromBody] PostNewEmploymentStatus postNewEmploymentStatus) { if (postNewEmploymentStatus == null) { return(Json(new { msg = "No Data" } )); } var orgId = getOrg(); var organisationDetails = await _context.Organisations.Where(x => x.Id == orgId).FirstOrDefaultAsync(); try { var orgEmployType = _context.EmploymentStatuses.Where(x => x.Id == Guid.Parse(postNewEmploymentStatus.AId)).FirstOrDefault(); orgEmployType.EmploymentStatusName = postNewEmploymentStatus.EmploymentStatusName; orgEmployType.Description = postNewEmploymentStatus.Description; _context.Update(orgEmployType); _context.SaveChanges(); return(Json(new { msg = "Success" } )); } catch (Exception ee) { } return(Json( new { msg = "Fail" })); }