public async Task <IHttpActionResult> ChangeImageAsync([FromBody] ChangeImageRequest request) { User user = await GetCurrentUserAsync() ?? throw new ActionForbiddenException(); await _profileService.ChangeImageAsync(user, request.Id); await UnitOfWork.SaveChangesAsync(); return(Ok()); }
public int ChangeImage(ChangeImageRequest request) { using (SqlConnection connection = new SqlConnection(_connectionString)) { var queryString = @"Update [User] Set ProfilePic = @ProfilePic Output inserted.Id Where [User].Id = @Id"; var imgUpdate = connection.QueryFirst <int>(queryString, request); return(imgUpdate); } throw new Exception("Could not change image"); }
public ActionResult ChangeImage(ChangeImageRequest request) { var imgUpdate = _connection.ChangeImage(request); return(Accepted(imgUpdate)); }