Example #1
0
        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"));
        }
Example #2
0
        public static RecipientDeleteDtoModel Map(RecipientDeleteViewModel viewModel)
        {
            var dtoModel = new RecipientDeleteDtoModel
            {
                RecipientId = viewModel.RecipientId
            };

            return(dtoModel);
        }