public async Task <IActionResult> Delete(RecipientDeleteViewModel deleteViewModel) { if (!this.User.IsInRole(GlobalConstants.AdministratorRoleName)) { return(this.Redirect("/Identity/Account/AccessDenied")); } if (!this.ModelState.IsValid) { var error = new RecipientError(); error.ErrorMessage = GlobalConstants.RecipientDeleteModelValidationMessege; return(this.RedirectToAction("Error", "Recipient", error)); } var dtoModel = RecipientDeleteViewMapper.Map(deleteViewModel); var isDelete = await this.recipientService.DeleteRecipientAsync(dtoModel); if (!isDelete) { var error = new RecipientError(); error.ErrorMessage = GlobalConstants.RecipientInvalidDeleteModelMessege; return(this.RedirectToAction("Error", "Recipient", error)); } return(this.Redirect("/Recipient/Index")); }
public async Task <IActionResult> Find(RecipientFindInputViewModel model) { if (!this.ModelState.IsValid) { return(this.Redirect("/Recipient/Find")); } var recipientId = await this.recipientService.FindRecipientAsync(model.Phone); if (recipientId == 0) { var error = new RecipientError(); error.ErrorMessage = GlobalConstants.RecipientFindErrorMessage; return(this.RedirectToAction("Error", "Recipient", error)); } return(this.RedirectToAction("Create", "Order", new { recipientId = recipientId })); }
public async Task <IActionResult> Create(RecipientParamsViewModel paramsRecipient) { if (!this.ModelState.IsValid) { return(this.Redirect("/Recipient/Home")); } bool ifExists = await this.recipientService.IfRecipientExistsAsync(paramsRecipient.Phone); if (ifExists) { var error = new RecipientError(); error.ErrorMessage = GlobalConstants.RecipientCreateErrorMessage; return(this.RedirectToAction("Error", "Recipient", error)); } var recipientId = await this.recipientService.CreateRecipientAsync(paramsRecipient); return(this.RedirectToAction("Create", "Order", new { recipientId = recipientId })); }
public async Task <IActionResult> Update(RecipientUpdateOutputViewModel outputViewModel) { if (!this.User.IsInRole(GlobalConstants.AdministratorRoleName)) { return(this.Redirect("/Identity/Account/AccessDenied")); } if (!this.ModelState.IsValid) { var error = new RecipientError(); error.ErrorMessage = GlobalConstants.RecipientUpdateModelValidationMessege; return(this.RedirectToAction("Error", "Recipient", error)); } var dtoModel = RecipientUpdateOutputViewMapper.Map(outputViewModel); var paramsDtoModel = await this.recipientService.GetRecipientParamsForUpdateAsync(dtoModel); var paramsViewModel = RecipientUpdateParamsMapper.Map(paramsDtoModel); return(this.View(paramsViewModel)); }
public IActionResult Error(RecipientError recipientError) { return(this.View(recipientError)); }