public async Task <IActionResult> NewJobCategory([FromBody] PostNewJobCategory postNewJobCategory) { if (postNewJobCategory == 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 { JobCategory newJobCategory = new JobCategory() { Id = Guid.NewGuid(), JobCategoryName = postNewJobCategory.JobCategory, Description = postNewJobCategory.Description, OrganisationId = orgId }; _context.Add(newJobCategory); _context.SaveChanges(); return(Json(new { msg = "Success" } )); } catch (Exception ee) { } return(Json( new { msg = "Fail" })); }
public async Task <IActionResult> editJobCategory([FromBody] PostNewJobCategory postNewJobCategory) { if (postNewJobCategory == null) { return(Json(new { msg = "No Data" } )); } var orgId = getOrg(); var organisationDetails = await _context.Organisations.Where(x => x.Id == orgId).FirstOrDefaultAsync(); try { var orgJobCat = _context.JobCategories.Where(x => x.Id == Guid.Parse(postNewJobCategory.AId)).FirstOrDefault(); orgJobCat.JobCategoryName = postNewJobCategory.JobCategory; orgJobCat.Description = postNewJobCategory.Description; _context.Update(orgJobCat); _context.SaveChanges(); return(Json(new { msg = "Success" } )); } catch (Exception ee) { } return(Json( new { msg = "Fail" })); }