Exemplo n.º 1
0
 public static User MapUserViewModelToUser(User user, UserViewModel userViewModel)
 {
     user.Email = userViewModel.Email;
     user.FirstName = userViewModel.FirstName;
     user.LastName = userViewModel.LastName;
     user.Address = userViewModel.Address;
     user.PhoneNumber = userViewModel.PhoneNumber;
     user.Id = userViewModel.Id;
     return user;
 }
Exemplo n.º 2
0
 public ActionResult UserProfile(string username = "******")
 {
     var userInfo = new User();
     var userVM = new UserViewModel();
     using (var context = new EventsDbContext())
     {
         userInfo = context.Users.Where(u => u.UserName == username).FirstOrDefault();
         userVM = ViewModelMapper.MapUserToUserViewModel(userInfo, userVM);
     }
     return View("Profile", userVM);
 }
Exemplo n.º 3
0
        public ActionResult UpdateProfile(UserViewModel userViewModel)
        {
            var userUpdated = new User();
            using (var context = new EventsDbContext())
            {
                var currentUser = context.Users.Find(userViewModel.Id);
                userUpdated = ViewModelMapper.MapUserViewModelToUser(currentUser, userViewModel);

                context.Entry(userUpdated).State = System.Data.Entity.EntityState.Modified;
                context.SaveChanges();
            }
            return Redirect("http://localhost:15716/Users/MyProfile");
        }
Exemplo n.º 4
0
        public ActionResult MyProfile()
        {
            User userInfo = new User();
            var userVM = new UserViewModel();
            using (var context = new EventsDbContext())
            {

                //userInfo = data.Users.GetUserInfo(User.Identity.Name);
                userInfo = context.Users.Where(u => u.UserName == User.Identity.Name).FirstOrDefault();
                userVM = ViewModelMapper.MapUserToUserViewModel(userInfo, userVM);
            }
            return View("MyProfile", userVM);
        }
Exemplo n.º 5
0
 public async Task<ActionResult> UpdateProfileAsync(UserViewModel userViewModel)
 {
     await Task.Run(() => UpdateProfile(userViewModel));
     return Redirect("http://localhost:15716/Users/MyProfile");
 }