public async Task <ActionResult> Create(BeneficiaryForm beneficiaryForm) { if (!ModelState.IsValid) { return(View(beneficiaryForm)); } var beneficiary = beneficiaryForm.ToBeneficiary(); var user = new ApplicationUser { UserName = beneficiaryForm.Email, Email = beneficiaryForm.Email }; try { await _beneficiaryService.Create(beneficiary, user, AppSettings.Theme); } catch (ApplicationException ex) { this.ModelState.AddModelError("", ex.Message); return(View(beneficiaryForm)); } return(RedirectToAction("Index", new BeneficiaryListFiltersModel().GetRouteValues()).WithSuccess("Beneficiario Creado")); }
public ActionResult Edit(int id, BeneficiaryForm beneficiaryForm) { if (!ModelState.IsValid) { return(View(beneficiaryForm)); } _beneficiaryService.Edit(beneficiaryForm.ToBeneficiary()); return(RedirectToAction("Index", new BeneficiaryListFiltersModel().GetRouteValues()).WithSuccess("Beneficiario Editado")); }
public async Task <ActionResult> AddBeneficiary(BeneficiaryForm addBeneficiaryForm) { if (!ModelState.IsValid) { return(View(addBeneficiaryForm)); } var beneficiary = addBeneficiaryForm.ToBeneficiary(); beneficiary.Town = _townService.GetById(addBeneficiaryForm.TownId); if (addBeneficiaryForm.EducationalInstitutionId.HasValue) { beneficiary.EducationalInstitution = _educationalInstitutionService.GetById(addBeneficiaryForm.EducationalInstitutionId.Value); } await _notificationService.SendAddBeneficiaryRequestEmail(beneficiary, addBeneficiaryForm.Email, AppSettings.Theme); return(RedirectToAction("Index").WithSuccess("Su solicitud ha sido enviada correctamente")); }