Пример #1
0
        private User toModel(UserViewModel vm)
        {
            var address = new Address();
            if (vm.Address != null) {
                address.Id = vm.Address.Id;
                address.City = vm.Address.City;
                address.Street = vm.Address.Street;
                address.BuildingNumber = vm.Address.BuildingNumber;
                address.ApartmentNumber = vm.Address.ApartmentNumber;
            }

            return new User {
                Address = address,
                FirstName = vm.FirstName,
                LastName = vm.LastName,
                Id = vm.Id
            };
        }
Пример #2
0
 public ActionResult Edit(UserViewModel vm)
 {
     var user = UserService.Save(vm);
     return View(user);
 }
Пример #3
0
 public UserViewModel Save(UserViewModel vm)
 {
     var savedUser = _userRepository.Save(toModel(vm));
     return toViewModel(savedUser);
 }
Пример #4
0
 public ActionResult Create(UserViewModel vm)
 {
     var savedUser = UserService.Save(vm);
     return RedirectToAction("Edit", new {id = savedUser.Id});
 }