public bool Update(int id, SYS_Layer_Account model) { if (model == null) { throw new ArgumentNullException(); } try { using (var context = new SystemEntities()) { var baseModel = context.SYS_Layer_Account.FirstOrDefault(f => f.ID.Equals(id)); if (baseModel == null) { throw new NullReferenceException("Không tìm thấy đối tượng trong cơ sở dữ liệu"); } else { model.ID = id; context.Entry(baseModel).CurrentValues.SetValues(model); //context.Entry(model).State = System.Data.Entity.EntityState.Modified; //context.SYS_Layer_Account.Attach(model); return(context.SaveChanges() > 0); } } } catch (Exception e) { throw e; } }
public bool Update(string id, SYS_GroupLayer model) { if (model == null) { throw new ArgumentNullException(); } try { using (var context = new SystemEntities()) { var baseModel = context.SYS_GroupLayer.FirstOrDefault(f => f.ID.Equals(id)); if (baseModel == null) { throw new NullReferenceException("Không tìm thấy đối tượng trong cơ sở dữ liệu"); } else { model.ID = id; context.Entry(baseModel).CurrentValues.SetValues(model); return(context.SaveChanges() > 0); } } } catch (Exception e) { throw e; } }
public ActionResult Edit(Genero genero) { if (ModelState.IsValid) { db.Entry(genero).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(genero)); }
public ActionResult Edit(Transportadora transportadora) { if (ModelState.IsValid) { db.Entry(transportadora).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(transportadora)); }
public ActionResult Edit(Veiculo veiculo) { if (ModelState.IsValid) { db.Entry(veiculo).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.TransportadoraId = new SelectList(db.Transportadora, "ID", "Nome", veiculo.TransportadoraId); return(View(veiculo)); }
public ActionResult Edit(Excurcao excurcao) { if (ModelState.IsValid) { db.Entry(excurcao).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.GeneroId = new SelectList(db.Genero, "ID", "Nome", excurcao.GeneroId); ViewBag.GuiaId = new SelectList(db.Guia, "ID", "Nome", excurcao.GuiaId); ViewBag.VeicuiloId = new SelectList(db.Veiculo, "VeiculoId", "MarcaCarro", excurcao.VeicuiloId); return(View(excurcao)); }
public ActionResult Edit(Reserva reserva) { if (ModelState.IsValid) { reserva.Username = User.Identity.Name.ToString(); reserva.SessionID = Session.SessionID.ToString(); reserva.OrderDate = DateTime.Now; db.Entry(reserva).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.ExcurcaoId = new SelectList(db.Excurcao, "ID", "Titulo", reserva.ExcurcaoId); return(View(reserva)); }