private Fincas ToFinca(FincasView view, string pic) { return(new Fincas { CiudadFinca = view.CiudadFinca, EstadoFinca = view.EstadoFinca, HabilitadaFinca = view.HabilitadaFinca, ImagePath = pic, IngresoFinca = view.IngresoFinca, NombreFinca = view.NombreFinca, FincaId = view.FincaId, PaisFinca = view.PaisFinca, }); }
public async Task <ActionResult> Edit(FincasView view) { if (ModelState.IsValid) { var pic = view.ImagePath; var folder = "~/Content/Fincas"; if (view.ImageFile != null) { pic = FilesHelper.UploadPhoto(view.ImageFile, folder); pic = string.Format("{0}/{1}", folder, pic); } var Finca = this.ToFinca(view, pic); db.Entry(Finca).State = EntityState.Modified; await db.SaveChangesAsync(); return(RedirectToAction("Index")); } return(View(view)); }