Ejemplo n.º 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));
        }
Ejemplo n.º 2
0
        public ActionResult DeleteConfirmed(Guid id)
        {
            TransportationLog transportationLog = db.TransportationLog.Find(id);

            db.TransportationLog.Remove(transportationLog);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Ejemplo n.º 3
0
        // Funkcija "zapri voznjo"
        public ActionResult CloseLog(string idLog)
        {
            //TransportationStatus transportationStatus = db.TransportationStatus.Where(t => t.TransportationLogID == Guid.Parse(idLog));
            //TransportationStatus transportationStatus = new TransportationStatus();
            //var x = db.TransportationStatus.Where(t => t.TransportationLogID == Guid.Parse(idLog));
            //TransportationStatus transportationStatus = db.TransportationStatus.Find(Guid.Parse(idLog));
            //var transportationStatus = db.TransportationStatus.Include(t => t.TransportationLog).Include(t => t.TransportationStatusTypes).Where(x => x.TransportationLogID == Guid.Parse(idLog));

            //TransportationStatus transportationStatus = db.TransportationStatus.Where(t => t.TransportationLogID == Guid.Parse("62416e0c - 2332 - 4836 - bac7 - 3889aaa32491"));
            //var x = db.TransportationStatus.Where(t => t.TransportationLogID == Guid.Parse(idLog));

            //TransportationStatus transportationStatus = new TransportationStatus();

            Guid tempID = Guid.Parse(idLog);
            TransportationStatus transportationStatus = db.TransportationStatus.Where(x => x.TransportationLogID == tempID).Single();

            Guid idOpen = Guid.Parse("cbaa33cc-ed89-448d-a371-72bafa5a4ff8");

            if (transportationStatus.TransportationTypeStatusID == idOpen)
            {
                TransportationStatus transportationStatus1 = new TransportationStatus();
                transportationStatus1.TransportationStatusID = Guid.NewGuid();

                transportationStatus1.DateCreated  = DateTime.Now;
                transportationStatus1.DateModified = transportationStatus1.DateCreated;

                transportationStatus1.CreatedBy  = Guid.Parse(User.Identity.GetUserId());
                transportationStatus1.ModifiedBy = transportationStatus1.CreatedBy;

                transportationStatus1.Date = DateTime.Now;

                transportationStatus1.TransportationTypeStatusID = Guid.Parse("6f754707-37b8-425b-88bd-d1515949e7cd");
                transportationStatus1.TransportationLogID        = Guid.Parse(idLog);

                db.TransportationStatus.Add(transportationStatus1);
                db.SaveChanges();

                // transportation log = neaktiven
                TransportationLog model = db.TransportationLog.Find(tempID);

                model.Active = false;

                db.Entry(model).State = EntityState.Modified;
                db.SaveChanges();

                return(RedirectToAction("Index"));
            }

            return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
        }
Ejemplo n.º 4
0
        // GET: TransportationLog/Delete/5
        public ActionResult Delete(Guid?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            TransportationLog transportationLog = db.TransportationLog.Find(id);

            if (transportationLog == null)
            {
                return(HttpNotFound());
            }
            return(View(transportationLog));
        }
Ejemplo n.º 5
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));
        }
Ejemplo n.º 6
0
        // GET: TransportationLog/Details/5
        public ActionResult Details(Guid?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            TransportationLog transportationLog = db.TransportationLog.Find(id);

            // tole je dodano za izpis tabele stroskov v view od trans log details
            var drivingCosts = db.DrivingCosts.Include(v => v.Costs).Include(v => v.TransportationLog).Where(x => x.TransportationLogID == transportationLog.TransportationLogID);

            ViewBag.DCosts = drivingCosts;

            // za prikaz tabele drivingCosts, ce so podatki
            var hasCosts = db.DrivingCosts.Where(x => x.TransportationLogID == transportationLog.TransportationLogID && x.TransportationLogID != null);

            ViewBag.hasCosts = hasCosts;

            if (transportationLog == null)
            {
                return(HttpNotFound());
            }
            return(View(transportationLog));
        }
Ejemplo n.º 7
0
        public ActionResult Create([Bind(Include = "ContainerID,VehicleID,CargoID,CustomerID,CostID,Date,Location,Note,Description")] TransportationLog transportationLog, bool checkHousehold = false, bool checkCosts = false)
        {
            if (ModelState.IsValid)
            {
                transportationLog.TransportationLogID = Guid.NewGuid();

                transportationLog.DateCreated  = DateTime.Now;
                transportationLog.DateModified = transportationLog.DateCreated;

                transportationLog.CreatedBy  = Guid.Parse(User.Identity.GetUserId());
                transportationLog.ModifiedBy = transportationLog.CreatedBy;

                transportationLog.Active = true;

                db.TransportationLog.Add(transportationLog);
                db.SaveChanges();


                // CHECKBOX za COSTS!

                /*if (checkCosts == true)
                 * {
                 *  Costs costs = new Costs();
                 *  costs.CostID = Guid.NewGuid();
                 *
                 *  costs.DateCreated = transportationLog.DateCreated;
                 *  costs.DateModified = transportationLog.DateModified;
                 *
                 *  costs.CreatedBy = transportationLog.CreatedBy;
                 *  costs.ModifiedBy = transportationLog.ModifiedBy;
                 *
                 *  costs.Amount = amount;
                 *  costs.Date = transportationLog.Date;
                 *  costs.Note = note;
                 *  costs.CostTypeID
                 *
                 *
                 *
                 *  db.Costs.Add(costs);
                 *  db.SaveChanges();
                 * }*/

                // tukaj dodaj za transporation status zapis
                //Guid latestTransporationLogID = transportationLog.TransportationLogID;
                TransportationStatus transportationStatus = new TransportationStatus();
                transportationStatus.TransportationStatusID = Guid.NewGuid();

                transportationStatus.DateCreated  = transportationLog.DateCreated;
                transportationStatus.DateModified = transportationLog.DateModified;

                transportationStatus.CreatedBy  = transportationLog.CreatedBy;
                transportationStatus.ModifiedBy = transportationLog.ModifiedBy;

                transportationStatus.Date = DateTime.Now;

                transportationStatus.TransportationTypeStatusID = Guid.Parse("cbaa33cc-ed89-448d-a371-72bafa5a4ff8");
                transportationStatus.TransportationLogID        = transportationLog.TransportationLogID;

                db.TransportationStatus.Add(transportationStatus);
                db.SaveChanges();

                // CHECKBOX za HOUSEHOLD!
                if (checkHousehold == true)
                {
                    return(RedirectToAction("Create", "HouseholdTransportation", new { LogID = transportationLog.TransportationLogID }));
                }

                return(RedirectToAction("Index"));
            }

            ViewBag.CargoID     = new SelectList(db.CargoTypes, "CargoID", "Name", transportationLog.CargoID);
            ViewBag.ContainerID = new SelectList(db.Containers, "ContainerID", "Name", transportationLog.ContainerID);
            //ViewBag.CostID = new SelectList(db.Costs, "CostID", "Note", transportationLog.CostID);
            ViewBag.CustomerID = new SelectList(db.Customers, "CustomerID", "Description", transportationLog.CustomerID);
            ViewBag.VehicleID  = new SelectList(db.Vehicles, "VehicleID", "Name", transportationLog.VehicleID);
            return(View(transportationLog));
        }