public async Task <IHttpActionResult> UpdateProblem(int id) { if (!user_service.IsAuthorizedToEditProblem(id)) { return(Unauthorized()); } // request contain must be of type multipart/form-data. if (!Request.Content.IsMimeMultipartContent()) { throw new HttpResponseException(HttpStatusCode.UnsupportedMediaType); } string root = HttpContext.Current.Server.MapPath("~/App_Data"); var provider = new MultipartFormDataStreamProvider(root); try{ // Read the form data. await Request.Content.ReadAsMultipartAsync(provider); } catch (Exception e) { return(InternalServerError(e)); } var problem_form = new ProblemCreationForm(provider.FormData, provider.FileData); FormDataValidationResult result = problem_form.Validate(); if (!result.IsValid) { return(new BadHttpRequest(result.ErrorMessages)); } try{ problem_repository.UpdateProblem(id, problem_form); } catch (ObjectNotFoundException e) { return(InternalServerError(e)); } return(Ok()); }