示例#1
0
        public ActionResult GetAllAssists()
        {
            using (MTCDBEntities db = new MTCDBEntities())
            {
                //var data = from a in db.Assists
                //           join d in db.Drivers on a.DriverID equals d.DriverID
                //           join c in db.Contractors on a.ContractorID equals c.ContractorID
                //           join f in db.FleetVehicles on a.FleetVehicleID equals f.FleetVehicleID
                //           join t in db.TowLocations on a.TowLocationID equals t.TowLocationID
                //           select new
                //           {
                //               AssistId = a.AssistID,
                //               AssistStartTime = a.OnSiteTime,
                //               AssistEndTime = a.x1098,
                //               Lat = a.Lat,
                //               Lon = a.Lon,
                //               DriverId = a.DriverID,
                //               DriverName = d.FirstName + " " + d.LastName,
                //               ContractorId = a.ContractorID,
                //               ContractorName = c.ContractCompanyName,
                //               FSPTruckNumber = f.FleetNumber,
                //               StartOD = a.StartOD,
                //               TowLocation = t.TowLocation1,
                //               Make = a.Make,
                //               LicensePlate = a.LicensePlate,
                //               State = a.State,
                //               Comments = a.Comments
                //           };

                var data = new List <String>();
                return(Json(data.ToList(), JsonRequestBehavior.AllowGet));
            }
        }
示例#2
0
        public static string BuildBackupCancellEmail(BackupRequest backupRequest)
        {
            StringBuilder sb = new StringBuilder();

            try
            {
                using (MTCDBEntities db = new MTCDBEntities())
                {
                    sb.Append(EmailBody(backupRequest));

                    var primaryContractor = GetContractorById(backupRequest.ContractorId);
                    sb.Append("<h3>2. The requestor " + primaryContractor.ContractCompanyName + " has cancelled the Back-up Request.</h3>");

                    sb.Append("<tr>");
                    sb.Append("<td><br/></td>");
                    sb.Append("</tr>");

                    sb.Append("<tr>");
                    sb.Append("<td colspan='2'><h3>Please log on to the LATATrax to respond. <a href='" + GetWebUri() + "/BackupTrucks/ResponseBackup' target='_blank'>Back-up Response</a>.</h3></td>");
                    sb.Append("</tr>");

                    sb.Append("<tr>");
                    sb.Append("<td><br/></td>");
                    sb.Append("</tr>");

                    sb.Append(EmailFooter());
                }
            }
            catch
            {
            }


            return(sb.ToString());
        }
示例#3
0
        public async Task <ActionResult> Edit()
        {
            EditAccountViewModel model = new EditAccountViewModel();

            if (User.Identity.IsAuthenticated)
            {
                var user = await UserManager.FindByIdAsync(User.Identity.GetUserId());

                model.UserId       = User.Identity.GetUserId();
                model.Email        = user.Email;
                model.FirstName    = user.FirstName;
                model.LastName     = user.LastName;
                model.NickName     = user.NickName;
                model.Mobile       = user.Mobile;
                model.Work         = user.PhoneNumber;
                model.ContractorId = user.ContractorId;

                using (MTCDBEntities db = new MTCDBEntities())
                {
                    ViewBag.Contractors = new SelectList(db.Contractors.OrderBy(p => p.ContractCompanyName).ToList(), "ContractorID", "ContractCompanyName", user.ContractorId);
                }
            }



            return(View(model));
        }
示例#4
0
        public ActionResult RemoveSchedule(Guid id)
        {
            using (MTCDBEntities db = new MTCDBEntities())
            {
                var response = new TransactionResult();
                try
                {
                    BeatSchedule bs = db.BeatSchedules.Find(id);
                    if (bs != null)
                    {
                        db.BeatBeatSchedules.RemoveRange(db.BeatBeatSchedules.Where(p => p.BeatScheduleID == bs.BeatScheduleID));
                        db.BeatSchedules.Remove(bs);
                        db.SaveChanges();
                    }

                    response.HasError = false;
                    response.Message  = String.Empty;
                }
                catch (Exception ex)
                {
                    response.HasError = true;
                    response.Message  = ex.InnerException.Message;
                }

                return(Json(response, JsonRequestBehavior.AllowGet));
            }
        }
示例#5
0
 public static Contractor GetContractorById(Guid contractorId)
 {
     using (MTCDBEntities db = new MTCDBEntities())
     {
         return(db.Contractors.FirstOrDefault(p => p.ContractorID == contractorId));
     }
 }
示例#6
0
        public ActionResult GetOrderDetails(int?id)
        {
            IEnumerable <Contractor> contractors;

            using (MTCDBEntities dc = new MTCDBEntities())
            {
                contractors = dc.Contractors.ToList();
            }

            using (MTCDbContext db = new MTCDbContext())
            {
                MerchandiseOrderDetailsViewModel model = new MerchandiseOrderDetailsViewModel();
                model.Order      = db.MerchandiseOrders.Find(id);
                model.CanCancel  = (model.Order.CreatedBy == HttpContext.User.Identity.Name ? true : false) && model.Order.MerchandiseOrderStatus == MerchandiseOrderStatus.OrderSubmitted;
                model.CanDecline = User.IsInRole("Admin");
                model.CanFulFill = User.IsInRole("Admin");
                model.Contractor = contractors.FirstOrDefault(p => p.ContractorID == model.Order.ContractorId).ContractCompanyName;
                model.Products   = db.MerchandiseOrderDetails.Where(p => p.MerchandiseOrderId == id).ToList().Select(d => new MerchandiseOrderProductsViewModel
                {
                    Id       = d.Id,
                    Product  = d.MerchandiseProduct.DisplayName,
                    UnitCost = d.UnitCost,
                    Quantity = d.Quantity
                }).ToList();
                model.Audits = GetAuditSummary(model.Order.Id);

                return(Json(model, JsonRequestBehavior.AllowGet));
            }
        }
示例#7
0
        public ActionResult Index()
        {
            using (MTCDBEntities db = new MTCDBEntities())
            {
                var model       = new List <MtcBeatSchedule>();
                var dbSchedules = db.GetDailySchedules();

                string weekdayFilter = "WD";
                if (DateTime.Today.DayOfWeek == DayOfWeek.Saturday || DateTime.Today.DayOfWeek == DayOfWeek.Sunday)
                {
                    weekdayFilter = "WE";
                }

                ViewBag.Heading = DateTime.Today.ToString("MMMM dd, yyyy") + " Schedule";


                foreach (var dbSchedule in dbSchedules)
                {
                    var itemIsValid = false;

                    //make sure contract of contracting company is still valid
                    var contracts = from q in db.Contracts
                                    join c in db.Contractors on q.ContractorID equals c.ContractorID
                                    where c.ContractCompanyName == dbSchedule.ContractCompanyName
                                    select q;

                    foreach (var contract in contracts)
                    {
                        if (contract.StartDate <= DateTime.Today && contract.EndDate >= DateTime.Today)
                        {
                            itemIsValid = true;
                        }
                    }

                    if (itemIsValid)
                    {
                        model.Add(new MtcBeatSchedule
                        {
                            BeatNumber          = dbSchedule.beatnumber,
                            ScheduleName        = dbSchedule.ScheduleName,
                            ScheduleTimeTable   = dbSchedule.ScheduleTimeTable,
                            Supervisor          = dbSchedule.Supervisor,
                            CellPhone           = dbSchedule.CellPhone,
                            ContractCompanyName = dbSchedule.ContractCompanyName,
                            PhoneNumber         = dbSchedule.PhoneNumber,
                            Weekday             = dbSchedule.Weekday
                        });
                    }
                }

                if (model.Count() > 1)
                {
                    return(View(model.Where(p => p.Weekday == weekdayFilter).OrderBy(p => p.BeatNumber).ThenBy(p => p.ScheduleName)));
                }
                else
                {
                    return(View(model));
                }
            }
        }
示例#8
0
        protected UserListViewModel GetCurrentUserContext()
        {
            UserListViewModel appUser = null;

            if (System.Web.HttpContext.Current.User != null)
            {
                using (var identity = new ApplicationDbContext())
                {
                    var userManager = new UserManager <ApplicationUser>(new UserStore <ApplicationUser>(identity));
                    appUser = new UserListViewModel(userManager.FindById(User.Identity.GetUserId()));
                }

                if (appUser.ContractorId != null)
                {
                    using (var db = new MTCDBEntities())
                    {
                        var contractor = db.Contractors.Include(f => f.ContractorType).FirstOrDefault(p => p.ContractorID == appUser.ContractorId);
                        if (contractor != null)
                        {
                            appUser.ContractorTypeName = contractor.ContractorType.ContractorTypeName;
                        }
                    }
                }
            }
            return(appUser);
        }
示例#9
0
 public ActionResult WeeklySchedule()
 {
     using (MTCDBEntities db = new MTCDBEntities())
     {
         return(View(db.BeatSchedules.ToList()));
     }
 }
示例#10
0
 public ActionResult Register()
 {
     using (MTCDBEntities db = new MTCDBEntities())
     {
         ViewBag.Contractors = new SelectList(db.Contractors.OrderBy(p => p.ContractCompanyName).ToList(), "ContractorID", "ContractCompanyName");
     }
     return(View());
 }
        public ActionResult Create()
        {
            ViewBag.AssetStatusId = new SelectList(db.AssetStatuses, "Id", "StatusName");
            using (MTCDBEntities dbOld = new MTCDBEntities())
            {
                ViewBag.VehicleId = new SelectList(dbOld.FleetVehicles.OrderBy(p => p.FleetNumber).ToList(), "FleetVehicleID", "FleetNumber");
            }

            return(View());
        }
示例#12
0
 public ActionResult DeleteConfirmed(Guid id)
 {
     using (MTCDBEntities db = new MTCDBEntities())
     {
         BeatSchedule BeatSchedule = db.BeatSchedules.Find(id);
         db.BeatSchedules.Remove(BeatSchedule);
         db.SaveChanges();
         return(RedirectToAction("WeeklySchedule"));
     }
 }
示例#13
0
        public ActionResult GetFreewaysByDirection(string name_startsWith)
        {
            using (var db = new MTCDBEntities())
            {
                var freeways = from q in db.Freeways
                               where q.FreewayName.StartsWith(name_startsWith)
                               orderby q.FreewayName
                               select q.FreewayName;

                return(Json(freeways.ToList(), JsonRequestBehavior.AllowGet));
            }
        }
示例#14
0
 public ActionResult DeleteWeeklySchedule(Guid id)
 {
     using (MTCDBEntities db = new MTCDBEntities())
     {
         BeatSchedule BeatSchedule = db.BeatSchedules.Single(r => r.BeatScheduleID == id);
         if (BeatSchedule == null)
         {
             return(HttpNotFound());
         }
         return(View(BeatSchedule));
     }
 }
示例#15
0
        /// <summary>
        ///     Make this later role depending
        /// </summary>
        /// <param name="name_startsWith"></param>
        /// <returns></returns>
        public ActionResult GetLocations(string name_startsWith)
        {
            using (var db = new MTCDBEntities())
            {
                var locations = from q in db.Locations
                                where q.Location1.StartsWith(name_startsWith)
                                orderby q.Location1
                                select q.LocationCode;

                return(Json(locations.ToList(), JsonRequestBehavior.AllowGet));
            }
        }
示例#16
0
 public ActionResult GetBeatSchedules()
 {
     using (var db = new MTCDBEntities())
     {
         var data = from q in db.BeatSchedules
                    select new
         {
             Id   = q.BeatScheduleID,
             Text = q.ScheduleName
         };
         return(Json(data.OrderBy(p => p.Text).ToList(), JsonRequestBehavior.AllowGet));
     }
 }
示例#17
0
 protected List <CHPOfficerViewModel> GetCHPOfficerList()
 {
     using (var db = new MTCDBEntities())
     {
         var officers = from c in db.CHPOfficers
                        select new CHPOfficerViewModel
         {
             Id             = c.Id,
             OfficeFullName = c.OfficerLastName + ", " + c.OfficerFirstName
         };
         return(officers.ToList());
     }
 }
示例#18
0
 protected List <BeatViewModel> GetBeatList()
 {
     using (var db = new MTCDBEntities())
     {
         var beats = from b in db.BeatDatas
                     select new BeatViewModel
         {
             BeatId     = b.ID,
             BeatNumber = b.BeatName
         };
         return(beats.ToList());
     }
 }
示例#19
0
        public ActionResult GetVehicles()
        {
            using (var db = new MTCDBEntities())
            {
                var data = from q in db.FleetVehicles
                           select new
                {
                    Id   = q.FleetVehicleID,
                    Text = q.VehicleNumber
                };

                return(Json(data.OrderBy(p => p.Text).ToList(), JsonRequestBehavior.AllowGet));
            }
        }
示例#20
0
 protected List <DriverViewModel> GetDriverList()
 {
     using (var db = new MTCDBEntities())
     {
         var drivers = from c in db.Drivers
                       select new DriverViewModel
         {
             DriverId       = c.DriverID,
             DriverFullName = c.FirstName + " " + c.LastName,
             FSPIDNumber    = c.FSPIDNumber
         };
         return(drivers.ToList());
     }
 }
示例#21
0
        public ActionResult EditWeeklySchedule(BeatSchedule BeatSchedule)
        {
            using (MTCDBEntities db = new MTCDBEntities())
            {
                if (ModelState.IsValid)
                {
                    db.Entry(BeatSchedule).State = System.Data.Entity.EntityState.Modified;
                    db.SaveChanges();

                    return(RedirectToAction("WeeklySchedule"));
                }
                return(View(BeatSchedule));
            }
        }
示例#22
0
        public ActionResult GetDrivers()
        {
            using (var db = new MTCDBEntities())
            {
                var data = from q in db.Drivers
                           select new
                {
                    Id   = q.DriverID,
                    Text = q.LastName + ", " + q.FirstName
                };

                return(Json(data.OrderBy(p => p.Text).ToList(), JsonRequestBehavior.AllowGet));
            }
        }
示例#23
0
        public ActionResult GetCallSigns()
        {
            using (var db = new MTCDBEntities())
            {
                var data = from q in db.MTCBeatsCallSigns
                           select new
                {
                    Id   = q.BeatID,
                    Text = q.CallSign
                };

                return(Json(data.OrderBy(p => p.Text).ToList(), JsonRequestBehavior.AllowGet));
            }
        }
示例#24
0
        public ActionResult GetCHPOfficers()
        {
            using (var db = new MTCDBEntities())
            {
                var data = from q in db.CHPOfficers
                           select new
                {
                    q.Id,
                    Text = q.OfficerLastName + ", " + q.OfficerFirstName
                };

                return(Json(data.OrderBy(p => p.Text).ToList(), JsonRequestBehavior.AllowGet));
            }
        }
示例#25
0
 public ActionResult GetVehiclePositions()
 {
     using (var db = new MTCDBEntities())
     {
         //var data = from q in db.VehiclePositions
         //           select new
         //           {
         //               Id = q.VehiclePositionID,
         //               Text = q.VehiclePosition1
         //           };
         //return Json(data.OrderBy(p => p.Text).ToList(), JsonRequestBehavior.AllowGet);
         return(Json(true, JsonRequestBehavior.AllowGet));
     }
 }
示例#26
0
 protected List <VehicleViewModel> GetVehicleList()
 {
     using (var db = new MTCDBEntities())
     {
         var vehicles = from c in db.FleetVehicles
                        select new VehicleViewModel
         {
             FleetVehicleId = c.FleetVehicleID,
             VehicleMake    = c.VehicleMake,
             VehicleModel   = c.VehicleModel,
             VehicleNumber  = c.VehicleNumber
         };
         return(vehicles.ToList());
     }
 }
示例#27
0
 public ActionResult GetVehicleTypes()
 {
     using (var db = new MTCDBEntities())
     {
         var data = from q in db.VehicleTypeLUs
                    select new
         {
             q.Id,
             Text = q.Name + " (" + q.Code + ")",
             q.Code
         };
         return(Json(data.OrderBy(p => p.Text).ToList(), JsonRequestBehavior.AllowGet));
         //return Json(true, JsonRequestBehavior.AllowGet);
     }
 }
示例#28
0
        public ActionResult GetViolationDetails(int vid)
        {
            var vd = new ViolationDetail();

            using (var dbc = new MTCDbContext())
            {
                var violation = dbc.Violations.FirstOrDefault(p => p.Id == vid);

                if (violation == null)
                {
                    return(Json(vd, JsonRequestBehavior.AllowGet));
                }

                vd.Callsign          = violation.CallSign;
                vd.Status            = violation.ViolationStatusType.Name;
                vd.OffenseNumb       = violation.OffenseNumber;
                vd.Deduction         = violation.DeductionAmount;
                vd.Notes             = violation.Notes;
                vd.BeatId            = new Guid(violation.BeatId.ToString());
                vd.DriverId          = new Guid(violation.DriverId.ToString());
                vd.VehicleId         = new Guid(violation.FleetVehicleId.ToString());
                vd.Severity          = Enum.GetName(typeof(ViolationTypeSeverity), violation.ViolationType.ViolationTypeSeverity);
                vd.LengthOfViolation = violation.LengthOfViolation;
            }

            using (var db = new MTCDBEntities())
            {
                var dbDriver = db.Drivers.FirstOrDefault(p => p.DriverID == vd.DriverId);

                if (dbDriver != null)
                {
                    vd.Driver = $"{dbDriver.FirstName} {dbDriver.LastName}";
                }

                var beat = (from b in db.BeatDatas
                            where b.ID == vd.BeatId
                            select b.BeatName).FirstOrDefault();

                var vehicle = (from veh in db.FleetVehicles
                               where veh.FleetVehicleID == vd.VehicleId
                               select veh.FleetNumber).FirstOrDefault();

                vd.Beat         = beat;
                vd.FleetVehicle = vehicle;
            }

            return(Json(vd, JsonRequestBehavior.AllowGet));
        }
示例#29
0
        public ActionResult GetOrders()
        {
            IEnumerable <Contractor> contractors;

            using (MTCDBEntities dc = new MTCDBEntities())
            {
                contractors = dc.Contractors.ToList();
            }


            using (MTCDbContext db = new MTCDbContext())
            {
                var dateLimit = DateTime.Today.AddMonths(-3);

                var data = from o in db.MerchandiseOrders
                           where o.CreatedOn >= dateLimit || o.MerchandiseOrderStatus == MerchandiseOrderStatus.OrderSubmitted
                           select o;

                var returnList = data.OrderByDescending(p => p.Id).ToList().Select(q => new MerchandiseOrderHistoryViewModel
                {
                    Id                     = q.Id,
                    FriendlyId             = q.Id.ToString().PadLeft(8, "0"[0]),
                    ContactName            = q.ContactName,
                    ContactNumber          = q.ContactNumber,
                    Contractor             = contractors.FirstOrDefault(p => p.ContractorID == q.ContractorId).ContractCompanyName,
                    PickupDate             = q.PickupDate,
                    PickupTime             = q.PickupTime,
                    CreatedBy              = q.CreatedBy,
                    CreatedOn              = q.CreatedOn,
                    MerchandiseOrderStatus = q.MerchandiseOrderStatus,
                    OrderDetails           = db.MerchandiseOrderDetails.Where(p => p.MerchandiseOrderId == q.Id).ToList().Select(d => new MerchandiseOrderProductsViewModel
                    {
                        Id       = d.Id,
                        Product  = d.MerchandiseProduct.DisplayName,
                        UnitCost = d.UnitCost,
                        Quantity = d.Quantity
                    }).ToList()
                }).ToList();

                //if user is a contractor, only show them THEIR orders
                if (!string.IsNullOrEmpty(UsersContractorCompanyName))
                {
                    returnList = returnList.Where(p => p.Contractor == UsersContractorCompanyName).ToList();
                }

                return(Json(returnList, JsonRequestBehavior.AllowGet));
            }
        }
示例#30
0
 protected List <ContractorViewModel> GetContractorList()
 {
     using (var db = new MTCDBEntities())
     {
         var contractors = from c in db.Contractors
                           select new ContractorViewModel
         {
             ContractorId          = c.ContractorID,
             ContractorCompanyName = c.ContractCompanyName,
             Email       = c.Email,
             ContactName = c.ContactLastName + ", " + c.ContactFirstName,
             Phone       = c.OfficeTelephone
         };
         return(contractors.ToList());
     }
 }