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)); } }
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()); }
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)); }
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)); } }
public static Contractor GetContractorById(Guid contractorId) { using (MTCDBEntities db = new MTCDBEntities()) { return(db.Contractors.FirstOrDefault(p => p.ContractorID == contractorId)); } }
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)); } }
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)); } } }
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); }
public ActionResult WeeklySchedule() { using (MTCDBEntities db = new MTCDBEntities()) { return(View(db.BeatSchedules.ToList())); } }
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()); }
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")); } }
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)); } }
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)); } }
/// <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)); } }
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)); } }
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()); } }
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()); } }
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)); } }
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()); } }
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)); } }
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)); } }
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)); } }
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)); } }
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)); } }
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()); } }
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); } }
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)); }
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)); } }
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()); } }