public async System.Threading.Tasks.Task <HttpResponseMessage> UpdateUserAsync() { string path = HttpContext.Current.Server.MapPath("~/Uploads"); var multipartFormDataStreamProvider = new CustomUploadMultipartFormProvider(path); try { await Request.Content.ReadAsMultipartAsync(multipartFormDataStreamProvider); List <KeyValuePair <string, string> > formValues = FormUtlities.ParseFormKeys(multipartFormDataStreamProvider); User User = (User)HttpContext.Current.Session["currUser"]; List <string> paths = FormUtlities.filePaths(multipartFormDataStreamProvider);//need to insert to the db all images path User.Profileimage = paths.FirstOrDefault(); return(Request.CreateResponse(HttpStatusCode.OK, Update(User))); } catch (System.Exception e) { return(Request.CreateResponse(HttpStatusCode.InternalServerError, "Error while trying to upload files!")); } }
public async System.Threading.Tasks.Task <HttpResponseMessage> UpdateCompnayAsync() { string path = HttpContext.Current.Server.MapPath("~/Uploads"); var multipartFormDataStreamProvider = new CustomUploadMultipartFormProvider(path); try { await Request.Content.ReadAsMultipartAsync(multipartFormDataStreamProvider); List <KeyValuePair <string, string> > formValues = FormUtlities.ParseFormKeys(multipartFormDataStreamProvider); //var CompanyString = formValues.Find(el => el.Key.Equals("company")).Value; Company Company = (Company)HttpContext.Current.Session["currCompany"]; List <string> paths = FormUtlities.filePaths(multipartFormDataStreamProvider);//need to insert to the db all images path Company.LogoUrl = paths.FirstOrDefault(); return(Request.CreateResponse(Update(Company))); } catch (System.Exception e) { return(Request.CreateResponse(HttpStatusCode.InternalServerError, "Error while trying to upload files!")); } }
public async System.Threading.Tasks.Task <HttpResponseMessage> AddStandAsync() { string path = HttpContext.Current.Server.MapPath("~/Uploads"); var multipartFormDataStreamProvider = new CustomUploadMultipartFormProvider(path); try { await Request.Content.ReadAsMultipartAsync(multipartFormDataStreamProvider); List <KeyValuePair <string, string> > formValues = FormUtlities.ParseFormKeys(multipartFormDataStreamProvider); var workspaceString = formValues.Find(el => el.Key.Equals("stand")).Value; Stand Stand = JsonConvert.DeserializeObject <Stand>(workspaceString); List <string> paths = FormUtlities.filePaths(multipartFormDataStreamProvider);//need to insert to the db all images path Stand.Images = paths; return(Request.CreateResponse(HttpStatusCode.OK, AddStand(Stand))); } catch (System.Exception e) { return(Request.CreateResponse(HttpStatusCode.InternalServerError, "Error while trying to upload files!")); } }