예제 #1
0
        public ActionResult Create(FleetVehicle FleetVehicle)
        {
            if (ModelState.IsValid)
            {
                if (!db.FleetVehicles.Any(p => p.VehicleNumber == FleetVehicle.VehicleNumber))
                {
                    //if FleetVehicle does not exist yet
                    FleetVehicle.FleetVehicleID = Guid.NewGuid();
                    db.FleetVehicles.InsertOnSubmit(FleetVehicle);
                    db.SubmitChanges();
                }

                return(RedirectToAction("Index"));
            }

            var contractors = db.Contractors.OrderBy(p => p.ContractCompanyName).ToList();

            if (!String.IsNullOrEmpty(this.UsersContractorCompanyName))
            {
                contractors = contractors.Where(p => p.ContractCompanyName == this.UsersContractorCompanyName).ToList();
            }

            ViewBag.Contractors = contractors;
            return(View(FleetVehicle));
        }
예제 #2
0
        public ActionResult Edit(FleetVehicle FleetVehicle)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    db.FleetVehicles.Attach(FleetVehicle);
                    db.Refresh(RefreshMode.KeepCurrentValues, FleetVehicle);
                    db.SubmitChanges();

                    return(RedirectToAction("Index"));
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex.Message);
            }

            var contractors = db.Contractors.OrderBy(p => p.ContractCompanyName).ToList();

            if (!String.IsNullOrEmpty(this.UsersContractorCompanyName))
            {
                contractors = contractors.Where(p => p.ContractCompanyName == this.UsersContractorCompanyName).ToList();
            }

            ViewBag.Contractors = contractors;
            return(View(FleetVehicle));
        }
예제 #3
0
        public ActionResult DeleteConfirmed(Guid id)
        {
            FleetVehicle fleetVehicle = db.FleetVehicles.Find(id);

            db.FleetVehicles.Remove(fleetVehicle);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
예제 #4
0
        public ActionResult DeleteConfirmed(Guid id)
        {
            FleetVehicle FleetVehicle = db.FleetVehicles.Single(r => r.FleetVehicleID == id);

            db.FleetVehicles.DeleteOnSubmit(FleetVehicle);
            db.SubmitChanges();
            return(RedirectToAction("Index"));
        }
예제 #5
0
        //
        // GET: /AdminArea/Freeways/Details/5

        public ActionResult Details(Guid id)
        {
            FleetVehicle FleetVehicle = db.FleetVehicles.Single(r => r.FleetVehicleID == id);

            if (FleetVehicle == null)
            {
                return(HttpNotFound());
            }
            return(View(FleetVehicle));
        }
예제 #6
0
 public ActionResult Edit([Bind(Include = "FleetVehicleID,ContractorID,ProgramStartDate,FleetNumber,VehicleType,VehicleYear,VehicleMake,VehicleModel,VIN,LicensePlate,RegistrationExpireDate,InsuranceExpireDate,LastCHPInspection,Comments,ProgramEndDate,FAW,RAW,RAWR,GVW,GVWR,Wheelbase,Overhang,MAXTW,MAXTWCALCDATE,FuelType,VehicleNumber,IPAddress,TAIP,AgreementNumber")] FleetVehicle fleetVehicle)
 {
     if (ModelState.IsValid)
     {
         db.Entry(fleetVehicle).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.ContractorID = new SelectList(db.Contractors, "ContractorID", "Address", fleetVehicle.ContractorID);
     return(View(fleetVehicle));
 }
예제 #7
0
        public ActionResult RemoveFleetVehicle(Guid fleetVehicleId)
        {
            if (db.FleetVehicles.Any(p => p.FleetVehicleID == fleetVehicleId))
            {
                FleetVehicle fV = db.FleetVehicles.FirstOrDefault(p => p.FleetVehicleID == fleetVehicleId);
                if (fV != null)
                {
                    db.FleetVehicles.Remove(fV);
                    db.SaveChanges();
                }
            }

            return(Json(true, JsonRequestBehavior.AllowGet));
        }
예제 #8
0
        public ActionResult Details(Guid?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            FleetVehicle fleetVehicle = db.FleetVehicles.Find(id);

            if (fleetVehicle == null)
            {
                return(HttpNotFound());
            }
            return(View(fleetVehicle));
        }
예제 #9
0
        public ActionResult Edit(Guid?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            FleetVehicle fleetVehicle = db.FleetVehicles.Find(id);

            if (fleetVehicle == null)
            {
                return(HttpNotFound());
            }
            ViewBag.ContractorID = new SelectList(db.Contractors, "ContractorID", "Address", fleetVehicle.ContractorID);
            return(View(fleetVehicle));
        }
예제 #10
0
        public ActionResult Save([Bind(Include = "FleetVehicleID,ContractorID,ProgramStartDate,FleetNumber,VehicleType,VehicleYear,VehicleMake,VehicleModel,VIN,LicensePlate,RegistrationExpireDate,InsuranceExpireDate,LastCHPInspection,Comments,ProgramEndDate,FAW,RAW,RAWR,GVW,GVWR,Wheelbase,Overhang,MAXTW,MAXTWCALCDATE,FuelType,VehicleNumber,IPAddress,TAIP,AgreementNumber,IsBackup")] FleetVehicle fleetVehicle)
        {
            if (fleetVehicle.FleetVehicleID != null && fleetVehicle.FleetVehicleID != Guid.Empty)
            {
                db.Entry(fleetVehicle).State = EntityState.Modified;
            }
            else
            {
                fleetVehicle.FleetVehicleID = Guid.NewGuid();
                db.FleetVehicles.Add(fleetVehicle);
            }

            db.SaveChanges();

            return(Json(true, JsonRequestBehavior.AllowGet));
        }
예제 #11
0
        public async Task <string> AddDelivery(DeliveryModel delivery)
        {
            FleetModel fleet = await _transportRestService.GetFleet(delivery.EventId);

            if (fleet != null)
            {
                FleetVehicle vehicule = fleet.Vehicles.FirstOrDefault(p => p.DriverId == delivery.DriverId);
                if (vehicule != null)
                {
                    delivery.DriverName  = vehicule.DriverName;
                    delivery.VehicleId   = vehicule.VehicleId;
                    delivery.VehicleName = vehicule.VehicleName;
                    return(await _transportRestService.CreateDelivery(delivery));
                }
            }
            return(string.Empty);
        }
예제 #12
0
        public static void CreateAssist(UIIncidentDispatch incidentDispatch)
        {
            using (FSPDataContext dc = new FSPDataContext())
            {
                using (TowTruckServiceRef.TowTruckServiceClient service = new TowTruckServiceRef.TowTruckServiceClient())
                {
                    TowTruckServiceRef.IncidentIn thisIncident = new TowTruckServiceRef.IncidentIn();

                    Guid     IncidentID = Guid.NewGuid();
                    DateTime TimeStamp  = DateTime.Now;

                    Guid CreatedBy = MembershipExtensions.GetUserId();

                    thisIncident.IncidentID     = IncidentID;
                    thisIncident.FreewayID      = Convert.ToInt32(incidentDispatch.FreewayId);
                    thisIncident.LocationID     = dc.Locations.Where(p => p.LocationCode == incidentDispatch.LocationName).FirstOrDefault().LocationID;
                    thisIncident.TimeStamp      = TimeStamp;
                    thisIncident.CreatedBy      = CreatedBy;
                    thisIncident.Description    = incidentDispatch.Description;
                    thisIncident.IncidentNumber = String.Empty;

                    //create incident
                    service.AddIncident(thisIncident);

                    //for each truck create assit

                    foreach (var truck in incidentDispatch.SelectedTrucks)
                    {
                        TowTruckServiceRef.AssistReq thisAssist = new TowTruckServiceRef.AssistReq();
                        thisAssist.AssistID = Guid.NewGuid();

                        thisAssist.IncidentID = IncidentID;

                        FleetVehicle dbTruck = dc.FleetVehicles.Where(p => p.VehicleNumber == truck).FirstOrDefault();

                        thisAssist.FleetVehicleID = dbTruck.FleetVehicleID;
                        thisAssist.ContractorID   = dbTruck.ContractorID;

                        thisAssist.DispatchTime = DateTime.Now;
                        thisAssist.x1097        = DateTime.Now;
                        service.AddAssist(thisAssist);
                    }
                }
            }
        }
예제 #13
0
        //
        // GET: /AdminArea/Freeways/Edit/5

        public ActionResult Edit(Guid id)
        {
            var contractors = db.Contractors.OrderBy(p => p.ContractCompanyName).ToList();

            if (!String.IsNullOrEmpty(this.UsersContractorCompanyName))
            {
                contractors = contractors.Where(p => p.ContractCompanyName == this.UsersContractorCompanyName).ToList();
            }

            ViewBag.Contractors = contractors;
            FleetVehicle FleetVehicle = db.FleetVehicles.Single(r => r.FleetVehicleID == id);

            if (FleetVehicle == null)
            {
                return(HttpNotFound());
            }
            return(View(FleetVehicle));
        }
예제 #14
0
        public ActionResult PostIncidentDispatchAjax(String direction, String freeway, String location, String crossStreet1, String crossStreet2, String comments, string selectedTrucks)
        {
            Boolean returnValue = true;

            try
            {
                using (TowTruckServiceRef.TowTruckServiceClient service = new TowTruckServiceRef.TowTruckServiceClient())
                {
                    TowTruckServiceRef.IncidentIn thisIncident = new TowTruckServiceRef.IncidentIn();

                    Guid     IncidentID = Guid.NewGuid();
                    DateTime TimeStamp  = DateTime.Now;

                    Guid CreatedBy = MembershipExtensions.GetUserId();
                    var  trucks    = new JavaScriptSerializer().Deserialize <IEnumerable <SelectedTruck> >(selectedTrucks);


                    String firstTruckBeatNumber = trucks.FirstOrDefault().beatNumberString;

                    thisIncident.IncidentID     = IncidentID;
                    thisIncident.Direction      = direction;
                    thisIncident.FreewayID      = Convert.ToInt32(freeway);
                    thisIncident.LocationID     = dc.Locations.Where(p => p.LocationCode == location).FirstOrDefault().LocationID;
                    thisIncident.BeatSegmentID  = new Guid("00000000-0000-0000-0000-000000000000");
                    thisIncident.BeatNumber     = firstTruckBeatNumber;
                    thisIncident.TimeStamp      = TimeStamp;
                    thisIncident.CreatedBy      = CreatedBy;
                    thisIncident.Description    = comments;
                    thisIncident.CrossStreet1   = crossStreet1;
                    thisIncident.CrossStreet2   = crossStreet2;
                    thisIncident.IncidentNumber = String.Empty;
                    thisIncident.Location       = "na";

                    //create incident
                    service.AddIncident(thisIncident);



                    //for each truck create assit

                    foreach (var truck in trucks)
                    {
                        TowTruckServiceRef.AssistReq thisAssist = new TowTruckServiceRef.AssistReq();
                        thisAssist.AssistID = Guid.NewGuid();

                        thisAssist.IncidentID = IncidentID;

                        FleetVehicle dbTruck = dc.FleetVehicles.Where(p => p.VehicleNumber == truck.truckNumber).FirstOrDefault();

                        thisAssist.FleetVehicleID = dbTruck.FleetVehicleID;
                        thisAssist.ContractorID   = dbTruck.ContractorID;


                        thisAssist.DispatchTime = DateTime.Now;
                        thisAssist.x1097        = DateTime.Now;
                        service.AddAssist(thisAssist);
                    }
                }
            }
            catch
            {
                returnValue = false;
            }


            return(Json(returnValue, JsonRequestBehavior.AllowGet));
        }