public async Task <IActionResult> editDeductionType([FromBody] PostNewDeduction postNewDeduction) { if (postNewDeduction == null) { return(Json(new { msg = "No Data" } )); } var orgId = getOrg(); var organisationDetails = await _context.Organisations.Where(x => x.Id == orgId).FirstOrDefaultAsync(); //bool isAssign = true; //if (postNewDepartment. == Guid.Empty) //{ // isAssign = false; //} try { var DedType = _context.Deductions.Where(x => x.Id == Guid.Parse(postNewDeduction.FId)).FirstOrDefault(); DedType.DeductionType = postNewDeduction.DeductionType; DedType.Description = postNewDeduction.Description; _context.Update(DedType); _context.SaveChanges(); return(Json(new { msg = "Success" } )); } catch (Exception ee) { } return(Json( new { msg = "Fail" })); }
public async Task <IActionResult> AddDeduction([FromBody] PostNewDeduction postNewDeduction) { if (postNewDeduction == 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 { Deduction newDeduction = new Deduction() { Id = Guid.NewGuid(), DeductionType = postNewDeduction.DeductionType, Description = postNewDeduction.Description, OrganisationId = orgId }; _context.Add(newDeduction); _context.SaveChanges(); return(Json(new { msg = "Success" } )); } catch (Exception ee) { } return(Json( new { msg = "Fail" })); }