Exemple #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;
 }
Exemple #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);
 }
Exemple #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");
        }
Exemple #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);
        }