Ejemplo n.º 1
0
        public ActionResult Edit(UserMangementViewModel userMangementViewModel, HttpPostedFileBase fileBase)
        {
            if (fileBase != null)
            {
                if (fileBase.ContentLength > 0)
                {
                    using (MemoryStream ms = new MemoryStream())
                    {
                        fileBase.InputStream.CopyTo(ms);
                        byte[] fileArray = ms.GetBuffer();
                        userMangementViewModel.DisplayPicture = fileArray;
                    }
                }
            }
            var userProfileDto = _mapper.Map <UserProfileExtend>(userMangementViewModel);

            userProfileDto.UserId = User.Identity.GetUserId();
            if (!string.IsNullOrEmpty(userProfileDto.Id))
            {
                var oldPicture = _userProfileService.GetSingle(i => i.Id == userProfileDto.Id).DisplayPicture;
                if (oldPicture.Length > 0 && userProfileDto.DisplayPicture.Length <= 0)
                {
                    userProfileDto.DisplayPicture = oldPicture;
                }
                _userProfileService.Update(userProfileDto);
            }
            else
            {
                _userProfileService.Create(userProfileDto);
            }
            return(RedirectToAction(ProfileControllerAction.Index, routeValues: new { message = Messages.ProfileEditConfirmation }));
        }
Ejemplo n.º 2
0
        public async Task <ActionResult> Privacy(UserMangementViewModel userMangementViewModel)
        {
            var userSettingsDto = _mapper.Map <UserSettingsExtend>(userMangementViewModel);

            userSettingsDto.UserId = User.Identity.GetUserId();
            if (!string.IsNullOrEmpty(userSettingsDto.Id))
            {
                await _userSettingsService.UpdateAsync(userSettingsDto);
            }
            else
            {
                await _userSettingsService.CreateAsync(userSettingsDto);
            }
            return(RedirectToAction(ProfileControllerAction.Index, new { message = Messages.ProfileEditConfirmation }));
        }