Esempio n. 1
0
        public async Task <ApplicationUserDetailsViewModel> GetUserDetails(ApplicationUser user)
        {
            var result = new ApplicationUserDetailsViewModel
            {
                Id          = user.Id,
                FirstName   = user.FirstName,
                LastName    = user.Lastname,
                Email       = user.Email,
                PhoneNumber = user.PhoneNumber,
                JoinDate    = user.JoinDate,
                Roles       = await _userManager.GetRolesAsync(user)
            };

            return(result);
        }
        private void InfoWithAdditionalPermissions(ApplicationUser user, ApplicationUserDetailsViewModel model)
        {
            var isAdmin      = _permissionService.UserHasPermission(GetUserAndOrganization(), AdministrationPermissions.ApplicationUser);
            var usersProfile = User.Identity.GetUserId() == user.Id;

            if (isAdmin)
            {
                var roles = GetUserRoles(user.Id);
                model.Roles = _mapper.Map <IEnumerable <ApplicationRoleMiniViewModel> >(roles);
            }

            if (!isAdmin && !usersProfile)
            {
                model.BirthDay    = BirthdayDateTimeHelper.RemoveYear(model.BirthDay);
                model.PhoneNumber = null;
            }
        }
Esempio n. 3
0
        // GET: ApplicationUsers/Details/5
        public async Task <ActionResult> Details(string id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }

            ApplicationUser applicationUser = await _applicationUserRepository.GetByIdAsync(id);

            if (applicationUser == null)
            {
                return(HttpNotFound());
            }

            var viewModel = new ApplicationUserDetailsViewModel()
            {
                User            = Mapper.Map <ApplicationUserDto>(applicationUser),
                TotalOrders     = await _applicationUserRepository.GetToalOrdersByIdAsync(applicationUser.Id),
                OrdersTotalCost = await _applicationUserRepository.GetTotalOrdersCostByIdAsync(applicationUser.Id)
            };

            return(View(viewModel));
        }
Esempio n. 4
0
 public IActionResult EditUserDetails(ApplicationUserDetailsViewModel vm)
 {
     return(View("ViewUserDetails", vm));
 }