Beispiel #1
0
        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"));
        }
Beispiel #2
0
        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"));
        }
Beispiel #3
0
        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"));
        }