Exemplo n.º 1
0
        public ActionResult Create(DriverInteraction DriverInteraction)
        {
            if (ModelState.IsValid)
            {
                //if DriverInteraction does not exist yet
                DriverInteraction.InteractionID = Guid.NewGuid();

                db.DriverInteractions.InsertOnSubmit(DriverInteraction);
                db.SubmitChanges();


                return(RedirectToAction("Index"));
            }

            ViewBag.Contractors = db.Contractors.OrderBy(p => p.ContractCompanyName).ToList();
            ViewBag.Drivers     = (from q in db.Drivers
                                   select new
            {
                FullName = q.LastName + ", " + q.FirstName,
                DriverID = q.DriverID
            }).OrderBy(p => p.FullName);
            ViewBag.InteractionTypes = db.InteractionTypes.OrderBy(p => p.InteractionType1).ToList();


            return(View(DriverInteraction));
        }
Exemplo n.º 2
0
        public ActionResult Create(Driver Driver)
        {
            if (ModelState.IsValid)
            {
                //if Driver does not exist yet
                Driver.DriverID  = Guid.NewGuid();
                Driver.DateAdded = DateTime.Now;


                db.Drivers.InsertOnSubmit(Driver);
                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;

            ViewBag.Beats = db.vBeats.OrderBy(p => p.BeatNumber).ToList();
            return(View(Driver));
        }
Exemplo n.º 3
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));
        }
Exemplo n.º 4
0
        public ActionResult Save(String BeatID, String SelectedSchedules, String StartDate, String EndDate)
        {
            bool retvalue = false;

            try
            {
                dynamic result = JsonConvert.DeserializeObject(SelectedSchedules);

                if (result != null)
                {
                    //first remove all schedules for this beat
                    db.BeatBeatSchedules.DeleteAllOnSubmit(db.BeatBeatSchedules.Where(p => p.BeatID == Guid.Parse(BeatID)));

                    foreach (var item in result)
                    {
                        BeatBeatSchedule beatBeatSchedule = new Domain.Model.BeatBeatSchedule();
                        beatBeatSchedule.BeatBeatScheduleID = Guid.NewGuid();
                        beatBeatSchedule.BeatID             = Guid.Parse(BeatID);
                        beatBeatSchedule.BeatScheduleID     = Guid.Parse(item.ToString());
                        db.BeatBeatSchedules.InsertOnSubmit(beatBeatSchedule);
                    }

                    db.SubmitChanges();
                    retvalue = true;
                }
            }
            catch { }

            return(Json(retvalue, JsonRequestBehavior.AllowGet));
        }
Exemplo n.º 5
0
        public ActionResult Create(Location Location)
        {
            if (ModelState.IsValid)
            {
                //if Location does not exist yet
                Location.LocationID = Guid.NewGuid();
                db.Locations.InsertOnSubmit(Location);
                db.SubmitChanges();

                return(RedirectToAction("Index"));
            }

            return(View(Location));
        }
Exemplo n.º 6
0
        public ActionResult Create(InteractionType InteractionType)
        {
            if (ModelState.IsValid)
            {
                //if InteractionType does not exist yet
                InteractionType.InteractionTypeID = Guid.NewGuid();
                db.InteractionTypes.InsertOnSubmit(InteractionType);
                db.SubmitChanges();

                return(RedirectToAction("Index"));
            }

            return(View(InteractionType));
        }
Exemplo n.º 7
0
        public ActionResult Edit(User user)
        {
            if (ModelState.IsValid)
            {
                db.Users.Attach(user);
                db.Refresh(RefreshMode.KeepCurrentValues, user);
                db.SubmitChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.Roles       = db.Roles.OrderBy(p => p.RoleName).ToList();
            ViewBag.Contractors = db.Contractors.OrderBy(p => p.ContractCompanyName).ToList();
            return(View(user));
        }
Exemplo n.º 8
0
        public ActionResult Create(CHPOfficer CHPOfficer)
        {
            if (ModelState.IsValid)
            {
                //if CHPOfficer does not exist yet
                db.CHPOfficers.InsertOnSubmit(CHPOfficer);
                db.SubmitChanges();


                return(RedirectToAction("Index"));
            }

            return(View(CHPOfficer));
        }
Exemplo n.º 9
0
        public ActionResult Create(vDropZone vDropZone)
        {
            if (ModelState.IsValid)
            {
                //if vDropZone does not exist yet
                vDropZone.DropZoneID = Guid.NewGuid();
                db.vDropZones.InsertOnSubmit(vDropZone);
                db.SubmitChanges();


                return(RedirectToAction("Index"));
            }

            return(View(vDropZone));
        }
Exemplo n.º 10
0
        public ActionResult Create(Contractor Contractor)
        {
            if (ModelState.IsValid)
            {
                //if Contractor does not exist yet
                Contractor.ContractorID = Guid.NewGuid();
                db.Contractors.InsertOnSubmit(Contractor);
                db.SubmitChanges();


                return(RedirectToAction("Index"));
            }

            return(View(Contractor));
        }
Exemplo n.º 11
0
        public ActionResult Create(BeatSchedule BeatSchedule)
        {
            if (ModelState.IsValid)
            {
                if (!db.BeatSchedules.Any(p => p.ScheduleName == BeatSchedule.ScheduleName))
                {
                    BeatSchedule.BeatScheduleID = Guid.NewGuid();
                    db.BeatSchedules.InsertOnSubmit(BeatSchedule);
                    db.SubmitChanges();
                }

                return(RedirectToAction("Index"));
            }

            return(View(BeatSchedule));
        }
Exemplo n.º 12
0
        public ActionResult Create(Freeway Freeway)
        {
            if (ModelState.IsValid)
            {
                if (db.Freeways.Any(p => p.FreewayID == Freeway.FreewayID) == false)
                {
                    //if Freeway does not exist yet
                    db.Freeways.InsertOnSubmit(Freeway);
                    db.SubmitChanges();
                }

                return(RedirectToAction("Index"));
            }

            return(View(Freeway));
        }
Exemplo n.º 13
0
        public ActionResult Create(InspectionType InspectionType)
        {
            if (ModelState.IsValid)
            {
                if (db.InspectionTypes.Any(p => p.InspectionTypeID == InspectionType.InspectionTypeID) == false)
                {
                    //if InspectionType does not exist yet
                    db.InspectionTypes.InsertOnSubmit(InspectionType);
                    db.SubmitChanges();
                }

                return(RedirectToAction("Index"));
            }

            return(View(InspectionType));
        }
Exemplo n.º 14
0
        public ActionResult Create(ContractorManager ContractorManager)
        {
            if (ModelState.IsValid)
            {
                //if ContractorManager does not exist yet
                ContractorManager.ContractorManagerID = Guid.NewGuid();
                db.ContractorManagers.InsertOnSubmit(ContractorManager);
                db.SubmitChanges();


                return(RedirectToAction("Index"));
            }

            ViewBag.Contractors = db.Contractors.OrderBy(p => p.ContractCompanyName).ToList();
            return(View(ContractorManager));
        }
Exemplo n.º 15
0
        public ActionResult Create(VehiclePosition VehiclePosition)
        {
            if (ModelState.IsValid)
            {
                if (db.VehiclePositions.Any(p => p.VehiclePosition1 == VehiclePosition.VehiclePosition1) == false)
                {
                    //if VehiclePosition does not exist yet
                    VehiclePosition.VehiclePositionID = Guid.NewGuid();
                    db.VehiclePositions.InsertOnSubmit(VehiclePosition);
                    db.SubmitChanges();
                }

                return(RedirectToAction("Index"));
            }

            return(View(VehiclePosition));
        }
Exemplo n.º 16
0
        public ActionResult Create(TowLocation TowLocation)
        {
            if (ModelState.IsValid)
            {
                if (!db.TowLocations.Any(p => p.TowLocation1 == TowLocation.TowLocation1))
                {
                    //if TowLocation does not exist yet
                    TowLocation.TowLocationID = Guid.NewGuid();
                    db.TowLocations.InsertOnSubmit(TowLocation);
                    db.SubmitChanges();
                }

                return(RedirectToAction("Index"));
            }

            return(View(TowLocation));
        }
Exemplo n.º 17
0
        public ActionResult Create(TrafficSpeed TrafficSpeed)
        {
            if (ModelState.IsValid)
            {
                if (!db.TrafficSpeeds.Any(p => p.TrafficSpeed1 == TrafficSpeed.TrafficSpeed1))
                {
                    //if TrafficSpeed does not exist yet
                    TrafficSpeed.TrafficSpeedID = Guid.NewGuid();
                    db.TrafficSpeeds.InsertOnSubmit(TrafficSpeed);
                    db.SubmitChanges();
                }

                return(RedirectToAction("Index"));
            }

            return(View(TrafficSpeed));
        }
Exemplo n.º 18
0
        public ActionResult Create(ServiceType ServiceType)
        {
            if (ModelState.IsValid)
            {
                if (!db.ServiceTypes.Any(p => p.ServiceType1 == ServiceType.ServiceType1))
                {
                    //if ServiceType does not exist yet
                    ServiceType.ServiceTypeID = Guid.NewGuid();
                    db.ServiceTypes.InsertOnSubmit(ServiceType);
                    db.SubmitChanges();
                }

                return(RedirectToAction("Index"));
            }

            return(View(ServiceType));
        }
Exemplo n.º 19
0
        public ActionResult Create(YearlyCalendar yearlyCalendar)
        {
            if (ModelState.IsValid)
            {
                if (!db.YearlyCalendars.Any(p => p.dayName == yearlyCalendar.dayName))
                {
                    //if VehicleType does not exist yet
                    yearlyCalendar.DateID = Guid.NewGuid();
                    db.YearlyCalendars.InsertOnSubmit(yearlyCalendar);
                    db.SubmitChanges();
                }

                return(RedirectToAction("Index"));
            }

            return(View(yearlyCalendar));
        }
Exemplo n.º 20
0
        public ActionResult Create(InsuranceCarrier InsuranceCarrier)
        {
            if (ModelState.IsValid)
            {
                if (!db.InsuranceCarriers.Any(p => p.CarrierName == InsuranceCarrier.CarrierName))
                {
                    //if InsuranceCarrier does not exist yet
                    InsuranceCarrier.InsuranceID = Guid.NewGuid();
                    db.InsuranceCarriers.InsertOnSubmit(InsuranceCarrier);
                    db.SubmitChanges();
                }

                return(RedirectToAction("Index"));
            }

            return(View(InsuranceCarrier));
        }
Exemplo n.º 21
0
        public ActionResult Create(ContractCreateViewModel ContractCreateViewModel)
        {
            if (ModelState.IsValid)
            {
                //if Contract does not exist yet
                Guid contractId = Guid.NewGuid();
                ContractCreateViewModel.Contract.ContractID = contractId;
                ContractCreateViewModel.Contract.BeatID     = db.vBeats.FirstOrDefault().BeatID; //obsolete
                db.Contracts.InsertOnSubmit(ContractCreateViewModel.Contract);
                db.SubmitChanges();

                //add beats
                foreach (var beat in ContractCreateViewModel.SelectedBeats)
                {
                    ContractsBeat contractsBeat = new ContractsBeat();
                    contractsBeat.BeatID     = beat;
                    contractsBeat.ContractID = contractId;
                    db.ContractsBeats.InsertOnSubmit(contractsBeat);
                }
                db.SubmitChanges();

                return(RedirectToAction("Index"));
            }

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

            return(View(ContractCreateViewModel));
        }
Exemplo n.º 22
0
        public ActionResult Create(CHPInspection CHPInspection)
        {
            if (ModelState.IsValid)
            {
                //if CHPInspection does not exist yet
                CHPInspection.InspectionID = Guid.NewGuid();
                db.CHPInspections.InsertOnSubmit(CHPInspection);
                db.SubmitChanges();


                return(RedirectToAction("Index"));
            }

            ViewBag.Contractors     = db.Contractors.OrderBy(p => p.ContractCompanyName).ToList();
            ViewBag.FleetVehicles   = db.FleetVehicles.OrderBy(p => p.VehicleNumber).ToList();
            ViewBag.CHPOfficers     = db.CHPOfficers.OrderBy(p => p.OfficerLastName).ToList();
            ViewBag.InspectionTypes = db.InspectionTypes.OrderBy(p => p.InspectionType1).ToList();

            return(View(CHPInspection));
        }
Exemplo n.º 23
0
        public ActionResult Edit(Var var)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    db.Vars.Attach(var);
                    db.Refresh(RefreshMode.KeepCurrentValues, var);
                    db.SubmitChanges();

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

            return(View(var));
        }