public async Task <IActionResult> Put(string id, [FromForm] UserResourse userModel) { var user = await _userService.GetUserAsync(id); if (user == null) { return(NotFound()); } if (userModel.ProfilePicture != null) { user.ProfilePicture = userModel.ProfilePicture.ConvertToByteArray(); } var resourse = _mapper.Map(userModel, user); await _userService.UpdateUserAsync(resourse); return(Ok()); }
public bool SaveUserResourse(Guid userId, List <string> resourse) { var q = _context.UserResourses.Where(x => x.UserId == userId); _context.UserResourses.RemoveRange(q); var list = new List <UserResourse>(); resourse.ForEach(x => { if (!string.IsNullOrWhiteSpace(x)) { var model = new UserResourse(); model.UserId = userId; model.Resourse = x; list.Add(model); } }); _context.UserResourses.AddRange(list); return(_context.SaveChanges() > 0); }