Esempio n. 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"));
        }
Esempio n. 2
0
        public ActionResult AddBeneficiary()
        {
            BeneficiaryForm form = new BeneficiaryForm();

            form.Theme = AppSettings.Theme;
            return(View(form));
        }
Esempio n. 3
0
        public ActionResult Detail(int id)
        {
            var beneficiary = _beneficiaryService.GetById(id);

            var beneficiaryForm = BeneficiaryForm.Create(beneficiary, new ApplicationUser());

            return(View(beneficiaryForm));
        }
Esempio n. 4
0
        public ActionResult Create()
        {
            var beneficiaryForm = new BeneficiaryForm();

            beneficiaryForm.Theme = AppSettings.Theme;

            return(View(beneficiaryForm));
        }
Esempio n. 5
0
        private void newBeneficaryToolStripMenuItem_Click(object sender, EventArgs e)
        {
            BeneficiaryForm bForm = new BeneficiaryForm(null)
            {
                MdiParent = this
            };

            bForm.Show();
        }
Esempio n. 6
0
        public ActionResult Edit(int id)
        {
            var beneficiary     = _beneficiaryService.GetById(id);
            var user            = _userManager.FindById(beneficiary.UserId);
            var beneficiaryForm = BeneficiaryForm.Create(beneficiary, user);

            beneficiaryForm.Theme = AppSettings.Theme;

            return(View(beneficiaryForm));
        }
Esempio n. 7
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"));
        }
Esempio n. 8
0
 private void editToolStripMenuItem_Click(object sender, EventArgs e)
 {
     //TODO: Call the edit form with selected item ID
     if (lvBeneficiaries.SelectedItems.Count > 0)
     {
         var             itemIndex     = lvBeneficiaries.SelectedIndices[0];
         var             beneficiaryId = int.Parse(lvBeneficiaries.SelectedItems[0].Text);
         BeneficiaryForm bf            = new BeneficiaryForm(beneficiaryId)
         {
             MdiParent = this.MdiParent
         };
         bf.Show();
         this.Dispose();
     }
 }
Esempio n. 9
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"));
        }