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 AddBeneficiary() { BeneficiaryForm form = new BeneficiaryForm(); form.Theme = AppSettings.Theme; return(View(form)); }
public ActionResult Detail(int id) { var beneficiary = _beneficiaryService.GetById(id); var beneficiaryForm = BeneficiaryForm.Create(beneficiary, new ApplicationUser()); return(View(beneficiaryForm)); }
public ActionResult Create() { var beneficiaryForm = new BeneficiaryForm(); beneficiaryForm.Theme = AppSettings.Theme; return(View(beneficiaryForm)); }
private void newBeneficaryToolStripMenuItem_Click(object sender, EventArgs e) { BeneficiaryForm bForm = new BeneficiaryForm(null) { MdiParent = this }; bForm.Show(); }
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)); }
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")); }
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(); } }
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")); }