Exemplo n.º 1
0
        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));
        }
Exemplo n.º 2
0
        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)));
        }