예제 #1
0
        public IActionResult Save([FromForm] PersonViewModel obj)
        {
            if (!ModelState.IsValid)
            {
                return(View("Edit", obj));
            }

            var person = PersonViewModel.Convert(obj);

            repository.Persons.Save(person);
            return(Redirect("/Person/Index"));
        }
예제 #2
0
        public IActionResult Edit(int id)
        {
            var person = repository.Persons.ById(id);
            var obj    = PersonViewModel.Convert(person);

            if (obj != null)
            {
                return(View("Edit", obj));
            }
            else
            {
                return(NotFound());
            }
        }