Exemplo n.º 1
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);
                    }
                }
            }
        }
Exemplo n.º 2
0
 public ActionResult PostIncidentDispatch(UIIncidentDispatch incidentDispatch)
 {
     Util.CreateAssist(incidentDispatch);
     return(RedirectToAction("Index"));
 }