public IActionResult Create(String returnUrl) { if (String.IsNullOrEmpty(returnUrl)) { returnUrl = Request.Headers["Referer"].ToString(); } return(View("Edit", PersonTypeViewModelFactory.Create(new PersonTypeDto(), returnUrl))); }
public async Task <IActionResult> Details(int id) { var returnUrl = Request.Headers["Referer"].ToString(); var personType = await _personTypeRepo.GetPersonType(id); PersonTypeViewModel personTypeVM = PersonTypeViewModelFactory.Details(personType, returnUrl); return(View("Edit", personTypeVM)); }
public async Task <IActionResult> Edit(int id, string returnUrl = null) { if (String.IsNullOrEmpty(returnUrl)) { returnUrl = Request.Headers["Referer"].ToString(); } var personType = await _personTypeRepo.GetPersonType(id); PersonTypeViewModel personTypeVM = PersonTypeViewModelFactory.Edit(personType, returnUrl); return(View("Edit", personTypeVM)); }
public async Task <IActionResult> Edit([FromForm] PersonTypeViewModel personTypeVM) { if (ModelState.IsValid) { await _personTypeRepo.UpdatePersonType(personTypeVM.PersonType); TempData["message"] = "Your data has been updated successfully."; TempData["toasterType"] = ToasterType.success; return(RedirectToAction(nameof(Edit), new { id = personTypeVM.PersonType.Id, returnUrl = personTypeVM.ReturnUrl })); } else { TempData["message"] = "A problem has been ocurred while updating your data."; TempData["toasterType"] = ToasterType.info; } return(View("Edit", PersonTypeViewModelFactory.Edit(personTypeVM.PersonType, personTypeVM.ReturnUrl))); }
public async Task <IActionResult> Create([FromForm] PersonTypeViewModel personTypeVM) { if (ModelState.IsValid) { var newPersonType = await _personTypeRepo.AddPersonType(personTypeVM.PersonType); TempData["message"] = "Your data has been submitted successfully."; TempData["toasterType"] = ToasterType.success; //return RedirectToAction(nameof(Index)); return(RedirectToAction(nameof(Edit), new { id = newPersonType.Id, returnUrl = personTypeVM.ReturnUrl })); } TempData["message"] = "A problem has been ocurred while submitting your data."; TempData["toasterType"] = ToasterType.info; return(View("Edit", PersonTypeViewModelFactory.Create(personTypeVM.PersonType, personTypeVM.ReturnUrl))); }