public async Task <ActionResult> Edit(int id, FormCollection collection) { Transport transport = new Transport(); if (ModelState.IsValid) { transport = db.Transport.Find(id); transport.IndexNumber = collection["IndexNumber"]; transport.SerialNumber = collection["SerialNumber"]; transport.Status = int.Parse(collection["Status"]); TransportModels transportModels = new TransportModels(); if (int.TryParse(collection["TransportSelect2"], out int idModel)) { transportModels = db.TransportModels.Find(idModel); } transport.TransportModels = transportModels; db.Entry(transport).State = EntityState.Modified; await db.SaveChangesAsync(); return(RedirectToAction("Index")); } return(View(transport)); }
// GET: Models/Delete/5 public ActionResult Delete(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } TransportModels transportModels = db.TransportModels.Find(id); if (transportModels == null) { return(HttpNotFound()); } return(View(transportModels)); }
public ActionResult Create(FormCollection collection) { try { TransportModels transportModels = new TransportModels() { Name = collection["Name"], ChargingTime = decimal.Parse(collection["ChargingTime"]), Markup = decimal.Parse(collection["Markup"]) }; db.TransportModels.Add(transportModels); db.SaveChanges(); return(RedirectToAction("Index")); } catch (Exception ex) { return(View()); } }
public TransportProperties() { _properties = new SubDictItem(); transportModel = TransportModels.Newtonian; }