public async Task <IActionResult> pic([FromForm] UserProfileUpdateModel updateModel)
        {
            byte[] bytes;
            var    path = CreateDir("UserProfilePic");

            //CreateResult result = new CreateResult();
            //if (updateModel.File.Length > 0)
            //{

            //    var fileName = ContentDispositionHeaderValue.Parse(updateModel.File.ContentDisposition).FileName.Trim('"');
            //    using (var reader = new StreamReader(updateModel.File.OpenReadStream()))
            //    {
            //        string contentAsString = reader.ReadToEnd();
            //        bytes = new byte[contentAsString.Length * sizeof(char)];
            //        System.Buffer.BlockCopy(contentAsString.ToCharArray(), 0, bytes, 0, bytes.Length);
            //        var now = DateTimeOffset.Now;
            //        var file = new UserProfilePic()
            //        {
            //            Name = updateModel.File.FileName,
            //            File_stream = bytes,
            //            ParentPath = path,
            //            Creation_time = now,
            //            Last_access_time = now,
            //            Last_write_time = now,

            //        };
            //        result = _dataContext.CreateFile.CallStoredProc(file).ToList<CreateResult>().FirstOrDefault();
            //    }
            //}

            return(Ok());
        }
Example #2
0
 public BaseResponse <bool> UpdateProfile(string key, UserProfileUpdateModel model)
 {
     try
     {
         if (model == null)
         {
             return(BaseResponse <bool> .BadRequest());
         }
         var user = Find(key);
         if (user == null)
         {
             return(BaseResponse <bool> .NotFound());
         }
         user.InjectFrom(model);
         _db.Update(user);
         var succced = _db.SaveChanges() == 1;
         if (succced)
         {
             return(BaseResponse <bool> .Success());
         }
         return(BaseResponse <bool> .BadRequest());
     }
     catch (Exception ex)
     {
         return(BaseResponse <bool> .InternalServerError(message : ex.Message, fullMsg : ex.StackTrace));
     }
 }
Example #3
0
        public IActionResult Pro(string key, [FromBody] UserProfileUpdateModel model)
        {
            MockToken();
            var user   = this.User;
            var result = _accountsRequestService.UpdateProfile(key, model);

            return(Ok(result));
        }
Example #4
0
        public async Task <IActionResult> UpdateMyUserProfile([FromBody] UserProfileUpdateModel model)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            var userId = await _userService.UpdateUserProfileAsync(GetCurrentUserId <long>(), model, GetCurrentIdentity <long>());

            return(OkValueObject(userId));
        }
        public async Task UpdateProfileAsync([FromBody] UserProfileUpdateModel model)
        {
            var cp = _httpContextAccessor.HttpContext.User;

            var user = await _userManager.FindByNameAsync(cp.Identity.Name);

            _userFactory.ToEntity(model, user);

            user.UserName = user.Email;

            await _userManager.UpdateAsync(user);
        }
Example #6
0
 internal static UserProfileEntity ToEntity(this UserProfileUpdateModel model, int id) => new UserProfileEntity
 {
     Id          = id,
     Email       = model.Email,
     FirstName   = model.FirstName,
     LastName    = model.LastName,
     Color       = model.Color,
     Location    = model.Location,
     Bio         = model.Bio,
     UserRoleId  = model.UserRoleId,
     IsActivated = model.IsActivated
 };
        public async Task <IActionResult> UpdateUserProfile([FromBody] UserProfileUpdateModel userProfileUpdateModel)
        {
            try
            {
                var result = await profileService.UpdateUserProfile(userProfileUpdateModel);

                return(Ok(result));
            }
            catch (Exception ex)
            {
                return(HandleExcpetion(ex));
            }
        }
Example #8
0
        public async Task <long> UpdateUserProfileAsync(long id, UserProfileUpdateModel model, UserIdentity <long> issuer)
        {
            var user = _userRepository.GetEntityById(id);

            _mapper.Map(model, user);
            user.UpdateBy(issuer);

            _userRepository.Update(user);

            await _uow.SaveChangesAsync();

            return(user.Id);
        }
Example #9
0
        public async Task <ActionResult> UpdateUserInfo(int id, [FromBody] UserProfileUpdateModel model)
        {
            return(await Execute(async operation =>
            {
                var portalPermissions = (PortalPermission)(UserPermissions.FirstOrDefault(item => item.PermissionGroupId == 1)?.Permissions ?? 0);
                if (UserId != id && (portalPermissions & PortalPermission.ManageUserProfiles) == 0)
                {
                    throw CommonExceptions.AccessDenied(operation, StatusCodes.Status403Forbidden);
                }

                var entity = model.ToEntity(id);
                await userService.UpdateUserProfile(operation, entity);
            }));
        }
 public BaseResponse <bool> UpdateProfile(string key, UserProfileUpdateModel model, string host = "", string api = "")
 {
     try
     {
         var requestModel = new ApiRequestModel()
         {
             Host        = host,
             Api         = string.IsNullOrEmpty(api) ? $"api/Accounts/{key}" : api,
             RequestBody = model
         };
         var response = Put <bool>(requestModel);
         return(response);
     }
     catch (Exception ex)
     {
         return(BaseResponse <bool> .InternalServerError(message : ex.Message, fullMsg : ex.StackTrace));
     }
 }
Example #11
0
        public async Task <IActionResult> UpdateUser(int id, UserProfileUpdateModel userForUpdateDto)
        {
            if (id != int.Parse(User.FindFirst(ClaimTypes.NameIdentifier).Value))
            {
                return(Unauthorized());
            }

            var userFromRepo = await _repo.GetUser(id).ConfigureAwait(false);

            _mapper.Map(userForUpdateDto, userFromRepo);

            if (await _repo.SaveAll().ConfigureAwait(false))
            {
                return(NoContent());
            }

            throw new Exception($"Updating user {id} failed on save");
        }
Example #12
0
        public async Task <UserProfile> UpdateUserProfile(UserProfileUpdateModel model)
        {
            try
            {
                var user = await context.Users.FirstOrDefaultAsync(f => f.Id == userResolverService.UserId);

                user.Update(model.FullName, model.Email, model.CountryId, model.UniversityId);

                var entity = await context.UserProfile.Include(p => p.Foods).FirstOrDefaultAsync(f => f.Id == userResolverService.UserId);

                entity.Update(model.CoverFoodImageId, model.AvailableDays, model.AboutMe, model.Languages, model.Instagram, model.Twitter, model.Address.Country, model.Address.City).UpdateFoods(model.FoodIds);
                await context.SaveChangesAsync();

                return(mapper.Map <UserProfile>(entity));
            }
            catch (System.Exception e)
            {
                throw new System.Exception(e.Message);
            }
        }
        public async Task <string> UpdateProfile(UserProfileUpdateModel model, int userId)
        {
            var user = await UserManager.FindByIdAsync(userId.ToString());

            user.Email       = model.Email;
            user.FirstName   = model.Surname;
            user.LastName    = model.LastName;
            user.PhoneNumber = model.PhoneNumber;
            user.UserName    = model.UserName;

            var result = await UserManager.UpdateAsync(user);

            if (result.Succeeded)
            {
                return("");
            }
            else
            {
                return("A felhasználói profil módosítása sikertelen volt!");
            }
        }
Example #14
0
 public User ToEntity(UserProfileUpdateModel model, User entity)
 {
     return(_mapper.Map(model, entity));
 }
Example #15
0
        public IActionResult UpdateProfile(string key, [FromBody] UserProfileUpdateModel model)
        {
            var result = _accountService.UpdateProfile(Email, model);

            return(Ok(result));
        }
Example #16
0
 public UserProfileCommand(UserProfileUpdateModel userProfile)
 {
     UserProfile = userProfile;
 }
 public async Task <IActionResult> UpdateProfile(UserProfileUpdateModel model)
 => await ProfileService.UpdateProfile(model, await GetCurrentUserIdAsync()) == ""
                 ? Ok() : (IActionResult)BadRequest();