public ActionResult Create(Foto Photo, HttpPostedFileBase image) { if (Photo.Location != "") { string stringLongLat = CheckLocation(Photo.Location); if (stringLongLat.StartsWith("Success")) { string[] coordenadas = stringLongLat.Split(':'); Photo.Latitude = Convert.ToDouble(coordenadas[1]); Photo.Longitude = Convert.ToDouble(coordenadas[2]); } } if (!ModelState.IsValid) { return View("Create", Photo); } else { string fileName = image.FileName.ToLower(); Photo.URLFoto = "/images/" + fileName; image.SaveAs(Server.MapPath("~" + Photo.URLFoto)); Photo.IdFoto = Context.Fotos.Max(f => f.IdFoto)+1; Context.Fotos.Add(Photo); return View("Indice",Context.Fotos); } }
public ActionResult Create() { Foto photo = new Foto(); return View("Create", photo); }