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));
        }
Ejemplo n.º 2
0
        // 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));
        }
Ejemplo n.º 3
0
        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());
            }
        }
Ejemplo n.º 4
0
 public TransportProperties()
 {
     _properties    = new SubDictItem();
     transportModel = TransportModels.Newtonian;
 }