public ActionResult Create(EstadisticaTransporte estadisticatransporte) { if (ModelState.IsValid) { db.EstadisticaTransporte.Add(estadisticatransporte); db.SaveChanges(); return RedirectToAction("Index"); } return View(estadisticatransporte); }
// POST api/EstadisticaTransporte public HttpResponseMessage PostEstadisticaTransporte(EstadisticaTransporte estadisticatransporte) { if (ModelState.IsValid) { db.EstadisticaTransporte.Add(estadisticatransporte); db.SaveChanges(); HttpResponseMessage response = Request.CreateResponse(HttpStatusCode.Created, estadisticatransporte); response.Headers.Location = new Uri(Url.Link("DefaultApi", new { id = estadisticatransporte.idMedios })); return response; } else { return Request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState); } }
// PUT api/EstadisticaTransporte/5 public HttpResponseMessage PutEstadisticaTransporte(int id, EstadisticaTransporte estadisticatransporte) { if (!ModelState.IsValid) { return Request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState); } if (id != estadisticatransporte.idMedios) { return Request.CreateResponse(HttpStatusCode.BadRequest); } db.Entry(estadisticatransporte).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException ex) { return Request.CreateErrorResponse(HttpStatusCode.NotFound, ex); } return Request.CreateResponse(HttpStatusCode.OK); }
public ActionResult Edit(EstadisticaTransporte estadisticatransporte) { if (ModelState.IsValid) { db.Entry(estadisticatransporte).State = EntityState.Modified; db.SaveChanges(); return RedirectToAction("Index"); } return View(estadisticatransporte); }