public async Task <IActionResult> Delete(HRCaseModel hrCaseModel) { //Call the API to save case var deleted = await _repository.DeleteHRCaseAsync(hrCaseModel.CaseId); if (!deleted) { ModelState.AddModelError(string.Empty, "Error: Unable to delete."); } return(RedirectToAction("List")); }
public async Task <IActionResult> Withdraw(HRCaseModel hrCaseModel) { //Call the API to save case var hrCase = new HRCase { hr_hrcaseid = hrCaseModel.CaseId, hr_casestatus = "315840006" }; //Withdrown by client var result = await _repository.UpdateHRCaseAsync(hrCase); if (result == null) { ModelState.AddModelError(string.Empty, "Error: Not able to withdraw."); return(View(hrCaseModel)); } else { TempData["CaseWithdrawn"] = "true"; return(RedirectToAction("List", "hrcase", "tabClosedCases")); } }
public async Task <IActionResult> Save(HRCaseModel hrCaseModel) { hrCaseModel.PRI = hrCaseModel.PRI.Replace("-", ""); if (ModelState.IsValid) { //Call the API to save case hrCaseModel.CaseStatusId = "315840002"; var hrCase = _mapper.Map <HRCase>(hrCaseModel); string caseId; if (string.IsNullOrEmpty(hrCaseModel.CaseId)) { caseId = await _repository.CreateHRCaseAsync(hrCase); } else { caseId = await _repository.UpdateHRCaseAsync(hrCase); } if (caseId != null) { TempData["CaseSaved"] = "true"; return(RedirectToAction("Update", new { id = caseId })); } else { ModelState.AddModelError("Error", "Error: Not able to connect to the database."); } } var caseTypes = await _caseTypeRepository.GetAllCaseTypesAsync(WebTemplateModel.TwoLetterCultureLanguage); var caseSubTypes = await _caseTypeRepository.GetAllCaseSubTypesAsync(WebTemplateModel.TwoLetterCultureLanguage); var caseStatuses = await _caseTypeRepository.GetAllCaseStatusesAsync(WebTemplateModel.TwoLetterCultureLanguage); hrCaseModel.CaseTypes = caseTypes; hrCaseModel.CaseSubTypes = caseSubTypes; hrCaseModel.CaseStatuses = caseStatuses; return(View(hrCaseModel)); }
public async Task <IActionResult> Create() { try { WebTemplateModel.Breadcrumbs.Add(new Breadcrumb { Href = "../hrcase/List", Title = _localizer["Home"] }); WebTemplateModel.Breadcrumbs.Add(new Breadcrumb { Href = "../hrcase/List", Title = _localizer["View My Cases"] }); WebTemplateModel.Breadcrumbs.Add(new Breadcrumb { Href = "", Title = _localizer["Add a new case"] }); var caseTypes = await _caseTypeRepository.GetAllCaseTypesAsync(WebTemplateModel.TwoLetterCultureLanguage); var caseSubTypes = await _caseTypeRepository.GetAllCaseSubTypesAsync(WebTemplateModel.TwoLetterCultureLanguage); var caseStatuses = await _caseTypeRepository.GetAllCaseStatusesAsync(WebTemplateModel.TwoLetterCultureLanguage); var caseModel = new HRCaseModel { CaseStatusId = "315840001", //New Case CaseTypes = caseTypes, CaseSubTypes = caseSubTypes, CaseStatuses = caseStatuses, FirstName = User.Claims.FirstOrDefault(c => c.Type == ClaimTypes.GivenName)?.Value, LastName = User.Claims.FirstOrDefault(c => c.Type == ClaimTypes.Surname)?.Value, Email = User.Claims.FirstOrDefault(c => c.Type == ClaimTypes.Email)?.Value, PRI = User.Claims.FirstOrDefault(c => c.Type == ClaimTypes.PrimarySid)?.Value }; return(View(caseModel)); } catch (Exception e) { _logger.LogDebug("Failed to create a case"); return(this.StatusCode(StatusCodes.Status500InternalServerError, "Database Failure")); } }
public async Task <IActionResult> Submit(HRCaseModel hrCaseModel) { hrCaseModel.CaseStatusId = "315840001"; var hrCase = _mapper.Map <HRCase>(hrCaseModel); string result = null; if (string.IsNullOrEmpty(hrCaseModel.CaseId)) { if (ModelState.IsValid) { hrCase.hr_pri = hrCaseModel.PRI.Replace("-", ""); result = await _repository.CreateHRCaseAsync(hrCase); } else { ModelState.AddModelError("Error", "Error: Not able to submit."); return(View()); } } else { result = await _repository.UpdateHRCaseAsync(hrCase); } if (result == null) { ModelState.AddModelError("Error", "Error: Not able to submit."); return(View(hrCaseModel)); } else { TempData["CaseSubmitted"] = "true"; return(RedirectToAction("List", "hrcase", "tabOpenCases")); } }