public async Task <string> Imgmodel() { Dictionary <string, object> dict = new Dictionary <string, object>(); try { var httpRequest = HttpContext.Current.Request; if (httpRequest.Files.Count > 0) { foreach (string file in httpRequest.Files) { var postedFile = httpRequest.Files[file]; var fileName = postedFile.FileName.Split('\\').LastOrDefault().Split('/').LastOrDefault(); var filePath = HttpContext.Current.Server.MapPath("~/Content/Upload/" + fileName); postedFile.SaveAs(filePath); Galery glr = new Galery(); glr.Url = "/Content/Upload/" + fileName; db.Galerys.Add(glr); db.SaveChanges(); return("/Content/Upload/" + fileName); } } } catch (Exception exception) { return(exception.Message); } return("no files"); }
public ActionResult <string> Post([Bind("dato", "temperature", "humidity", "pressure")] measurement value) { db.measurement.Add(value); db.SaveChanges(); return(value.dato + " " + value.humidity + " " + value.temperature + " " + value.pressure); }