public ActionResult Edit(int id) { var entity = UnitOfWork.AppChofereRepository.GetById(id); var input = new appChofereInput { Id = entity.Id, nombre = entity.nombre, foto = entity.foto, lic = entity.lic }; return PartialView("Create", input); }
public ActionResult Create(appChofereInput input) { if (!ModelState.IsValid) return PartialView(input); var entity = new appChoferes { nombre = input.nombre, foto = input.foto, lic = input.lic, usuario_Id=input.idUsuario }; UnitOfWork.AppChofereRepository.Insert(entity); UnitOfWork.Save(); return Json(MapToGridModel(entity)); // returning grid model, used in grid.api.renderRow }
public ActionResult Edit(appChofereInput input) { if (!ModelState.IsValid) return PartialView("Create", input); var entity = UnitOfWork.AppChofereRepository.GetById(input.Id); entity.nombre = input.nombre; entity.foto = input.foto; entity.lic = input.lic; UnitOfWork.AppChofereRepository.Update(entity); UnitOfWork.Save(); // returning the key to call grid.api.update return Json(new { input.Id }); }