Пример #1
0
        public ActionResult PersonalDetails(UserDetailsViewModel viewModel)
        {
            if (ModelState.IsValid)
            {
                var user = _context.UserProfiles.First(p => p.UserName.ToLower().Equals(viewModel.UserName.ToLower()));

                user.LastName = viewModel.LastName;
                user.FirstName = viewModel.FirstName;
                user.Email = viewModel.Email;
                user.DateOfBirth = viewModel.DateOfBirth;
                _context.SaveChanges();
                return RedirectToAction("Index", "User");
            }
            return View("UserPersonalDetailsView");
        }
Пример #2
0
        public ActionResult PersonalDetails()
        {
            UserDetailsViewModel vm = null;
            var user = _context.UserProfiles.FirstOrDefault(p => p.UserName.ToLower().Equals(User.Identity.Name));
            if (user != null)
            {

                vm = new UserDetailsViewModel
                    {
                        DateOfBirth = user.DateOfBirth,
                        Email = user.Email,
                        FirstName = user.FirstName,
                        LastName = user.LastName,
                        UserName = user.UserName,

                    };
            }

               return View("UserPersonalDetailsView", vm);
        }
Пример #3
0
 public ActionResult Index()
 {
     var user = _context.UserProfiles.FirstOrDefault(p => p.UserName.ToLower().Equals(User.Identity.Name));
     if (user != null)
     {
         var roleProvider = (SimpleRoleProvider)Roles.Provider;
         var vm = new UserDetailsViewModel
             {
                 DateOfBirth = user.DateOfBirth,
                 Email = user.Email,
                 FirstName = user.FirstName,
                 LastName = user.LastName,
                 UserName = user.UserName,
                 Role = roleProvider.GetRolesForUser(user.UserName).FirstOrDefault(),
                 Addresses = GetUserAddresses(user.UserId),
                 Phones = GetUserPhones(user.UserId)
             };
         return View("UserView", vm);
     }
     return View("UserView");
 }