Example #1
0
        public ActionResult Edit([Bind(Include = "TransportationLogID,ContainerID,VehicleID,CargoID,CustomerID,CostID,Date,Location,Note,Description")] TransportationLogViewModel TransportationLogViewModel)
        {
            if (ModelState.IsValid)
            {
                TransportationLog model = db.TransportationLog.Find(TransportationLogViewModel.TransportationLogID);

                model.Date        = TransportationLogViewModel.Date;
                model.Location    = TransportationLogViewModel.Location;
                model.Note        = TransportationLogViewModel.Note;
                model.Description = TransportationLogViewModel.Description;

                model.CargoID     = TransportationLogViewModel.CargoID;
                model.ContainerID = TransportationLogViewModel.ContainerID;
                model.CustomerID  = TransportationLogViewModel.CustomerID;
                model.VehicleID   = TransportationLogViewModel.VehicleID;
                //model.CostID = TransportationLogViewModel.CostID;

                model.DateModified = DateTime.Now;
                model.ModifiedBy   = Guid.Parse(User.Identity.GetUserId());

                db.Entry(model).State = EntityState.Modified;
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }
            ViewBag.CargoID     = new SelectList(db.CargoTypes, "CargoID", "Name", TransportationLogViewModel.CargoID);
            ViewBag.ContainerID = new SelectList(db.Containers, "ContainerID", "Label", TransportationLogViewModel.ContainerID);
            //ViewBag.CostID = new SelectList(db.Costs, "CostID", "Note", TransportationLogViewModel.CostID);
            ViewBag.CustomerID = new SelectList(db.Customers, "CustomerID", "Description", TransportationLogViewModel.CustomerID);
            ViewBag.VehicleID  = new SelectList(db.Vehicles, "VehicleID", "Name", TransportationLogViewModel.VehicleID);
            return(View(TransportationLogViewModel));
        }
Example #2
0
        // GET: TransportationLog/Edit/5
        public ActionResult Edit(Guid?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            TransportationLog transportationLog = db.TransportationLog.Find(id);

            var test = (from customer in db.Customers
                        select new
            {
                CustomerID = customer.CustomerID,
                Name = customer.CompanyID != null ? customer.Company.FullName : customer.PrivateCustomer.FullName
            }).OrderBy(x => x.Name);

            TransportationLogViewModel view = new TransportationLogViewModel();

            view.TransportationLogID = transportationLog.TransportationLogID;
            view.ContainerID         = transportationLog.ContainerID;
            view.VehicleID           = transportationLog.VehicleID;
            view.CargoID             = transportationLog.CargoID;
            view.CustomerID          = transportationLog.CustomerID;
            //view.CostID = transportationLog.CostID;
            view.Date        = transportationLog.Date;
            view.Location    = transportationLog.Location;
            view.Note        = transportationLog.Note;
            view.Description = transportationLog.Description;

            if (transportationLog == null)
            {
                return(HttpNotFound());
            }
            ViewBag.CargoID     = new SelectList(db.CargoTypes, "CargoID", "Name", transportationLog.CargoID);
            ViewBag.ContainerID = new SelectList(db.Containers, "ContainerID", "Label", transportationLog.ContainerID);
            //ViewBag.CostID = new SelectList(db.Costs, "CostID", "Note", transportationLog.CostID);
            ViewBag.CustomerID = new SelectList(test, "CustomerID", "Name", transportationLog.CustomerID);
            ViewBag.VehicleID  = new SelectList(db.Vehicles, "VehicleID", "Name", transportationLog.VehicleID);
            return(View(view));
        }