public IHttpActionResult Put(int id, KinderGartenModel kgm) { KinderGarten kg = MyService.GetById(id); if (kg != null) { kg.Address = kgm.Address; kg.Description = kgm.Description; kg.Cost = kgm.Cost; kg.Name = kgm.Name; kg.NbrEmp = kgm.NbrEmp; kg.Phone = kgm.Phone; kg.Image = kgm.Image; kg.longitude = kgm.longitude; kg.latitude = kgm.latitude; MyService.Update(kg); MyService.Commit(); } else { return(NotFound()); } return(Ok()); }
public ActionResult Edit(int id, KinderGartenModel tm, HttpPostedFileBase Image) { try { KinderGarten t = KindergartenService.GetById(id); t.Name = tm.Name; t.Image = Image.FileName; t.Description = tm.Description; t.NbrEmp = tm.NbrEmp; t.Phone = tm.Phone; t.Address = tm.Address; t.Cost = tm.Cost; var path = Path.Combine(Server.MapPath("~/Content/Uploads"), Image.FileName); Image.SaveAs(path); KindergartenService.Update(t); KindergartenService.Commit(); return(RedirectToAction("Index")); } catch (Exception ex) { return(View(tm)); } }