Beispiel #1
0
        public ActionResult GetBackupAssignments()
        {
            var beats = GetBeatList();

            using (var db = new MTCDbContext())
            {
                var backupBeats = db.BackupBeats.ToList();
                var data        = db.BackupAssignments.ToList().Select(p => new BackupAssignmentViewModel
                {
                    Id                        = p.Id,
                    BeatId                    = p.BeatId,
                    BeatNumber                = (from b in beats where b.BeatId == p.BeatId select b.BeatNumber).FirstOrDefault(),
                    PrimaryBackupBeatId       = p.PrimaryBackupBeatId,
                    PrimaryBackupBeatNumber   = beats.FirstOrDefault(b => b.BeatId == backupBeats.FirstOrDefault(t => t.Id == p.PrimaryBackupBeatId)?.BeatId)?.BeatNumber,
                    SecondaryBackupBeatId     = p.SecondaryBackupBeatId,
                    SecondaryBackupBeatNumber = beats.FirstOrDefault(b => b.BeatId == backupBeats.FirstOrDefault(t => t.Id == p.SecondaryBackupBeatId)?.BeatId)?.BeatNumber,
                    TertiaryBackupBeatId      = p.TertiaryBackupBeatId,
                    TertiaryBackupBeatNumber  = beats.FirstOrDefault(b => b.BeatId == backupBeats.FirstOrDefault(t => t.Id == p.TertiaryBackupBeatId)?.BeatId)?.BeatNumber,
                    CreatedBy                 = p.CreatedBy,
                    CreatedOn                 = p.CreatedOn,
                    ModifiedBy                = p.ModifiedBy,
                    ModifiedOn                = p.ModifiedOn
                });

                return(Json(data, JsonRequestBehavior.AllowGet));
            }
        }
Beispiel #2
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));
            }
        }
Beispiel #3
0
        private bool UndoOrder(int orderId, MerchandiseOrderStatus status)
        {
            bool retValue = true;

            using (MTCDbContext db = new MTCDbContext())
            {
                MerchandiseOrder order = db.MerchandiseOrders.Find(orderId);
                if (order != null)
                {
                    AuditMerchandiseOrder(order);
                    order.MerchandiseOrderStatus = status;
                    order.ModifiedBy             = HttpContext.User.Identity.Name;
                    order.ModifiedOn             = DateTime.Now;

                    //re-stock inventory
                    var orderProducts = db.MerchandiseOrderDetails.Where(p => p.MerchandiseOrderId == orderId).ToList();
                    foreach (var orderProduct in orderProducts)
                    {
                        MerchandiseProduct dbproduct = db.MerchandiseProducts.Find(orderProduct.MerchandiseProductId);
                        if (dbproduct != null)
                        {
                            dbproduct.UnitsInStock += orderProduct.Quantity;
                        }
                    }

                    db.SaveChanges();

                    SendEmails(order, true);
                }
            }

            return(retValue);
        }
Beispiel #4
0
        public async Task <ActionResult> ResolveTroubleTicket(int Id)
        {
            bool retValue = true;

            try
            {
                using (MTCDbContext db = new MTCDbContext())
                {
                    TroubleTicket troubleTicket = db.TroubleTickets.Find(Id);

                    if (troubleTicket != null)
                    {
                        this.AuditTroubleTicket(troubleTicket);

                        troubleTicket.TroubleTicketStatus = TroubleTicketStatus.Resolved;
                        troubleTicket.ModifiedBy          = HttpContext.User.Identity.Name;
                        troubleTicket.ModifiedOn          = DateTime.Now;

                        await db.SaveChangesAsync();
                    }


                    this.EmailTicketResolution(troubleTicket, db);
                }
            }
            catch
            {
                retValue = false;
            }

            return(Json(retValue, JsonRequestBehavior.AllowGet));
        }
Beispiel #5
0
        public static string BuildMerchandiseProductLowInventoryEmailBody(MerchandiseProduct product)
        {
            var sb = new StringBuilder();

            sb.Append("<h3>Low inventory for " + product.DisplayName + "</h3>");

            sb.Append("<table>");

            sb.Append("<tr>");
            sb.Append("<td>Product ID</td>");
            sb.Append("<td>" + product.Id + "</td>");
            sb.Append("</tr>");

            sb.Append("<tr>");
            sb.Append("<td>Display  Name</td>");
            sb.Append("<td>" + product.DisplayName + "</td>");
            sb.Append("</tr>");

            sb.Append("<tr>");
            sb.Append("<td>Current Inventory Level</td>");
            sb.Append("<td>" + product.UnitsInStock + "</td>");
            sb.Append("</tr>");

            sb.Append("</table>");

            using (MTCDbContext d = new MTCDbContext())
            {
                sb.Append("For further details of this product, please click <a href='" + d.MTCApplicationSettings.Where(p => p.Name == "WebRoot").FirstOrDefault().Value +
                          "/MerchandiseProducts/Edit?id=" + product.Id + "' target='_blank'>here</a>.");
            }

            return(sb.ToString());
        }
Beispiel #6
0
        public ActionResult RemoveCustomDate(int id)
        {
            using (MTCDbContext db = new MTCDbContext())
            {
                var response = new TransactionResult();
                try
                {
                    CustomDate CustomDate = db.CustomDates.Find(id);
                    if (CustomDate != null)
                    {
                        var customScheduleIds = db.CustomSchedules.Where(p => p.CustomDateId == id).Select(p => p.Id).ToList();
                        db.BeatCustomSchedules.RemoveRange(db.BeatCustomSchedules.Where(p => customScheduleIds.Contains(p.CustomScheduleId)));
                        db.CustomSchedules.RemoveRange(db.CustomSchedules.Where(p => p.CustomDateId == id));
                        db.CustomDates.Remove(CustomDate);
                        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));
            }
        }
Beispiel #7
0
        public ActionResult GetBackupProviders()
        {
            var beats       = GetBeatList();
            var contractors = GetContractorList();
            var vehicles    = GetVehicleList();

            using (var db = new MTCDbContext())
            {
                var data = db.BackupProviders.ToList().Select(p => new BackupProviderViewModel
                {
                    Id             = p.Id,
                    BackupBeatId   = p.BackupBeatId,
                    BeatId         = p.BackupBeat.BeatId,
                    Beat           = beats.FirstOrDefault(b => b.BeatId == p.BackupBeat.BeatId),
                    ContractorId   = p.ContractorId,
                    Contractor     = contractors.FirstOrDefault(c => c.ContractorId == p.ContractorId),
                    FleetVehicleId = p.FleetVehicleId,
                    FleetVehicle   = vehicles.FirstOrDefault(c => c.FleetVehicleId == p.FleetVehicleId),
                    CreatedBy      = p.CreatedBy,
                    CreatedOn      = p.CreatedOn,
                    ModifiedBy     = p.ModifiedBy,
                    ModifiedOn     = p.ModifiedOn
                });


                return(Json(data.ToList(), JsonRequestBehavior.AllowGet));
            }
        }
Beispiel #8
0
        public ActionResult SaveBackupBeat(BackupBeat model)
        {
            using (var db = new MTCDbContext())
            {
                if (model.Id == 0)
                {
                    model.CreatedOn  = DateTime.Now;
                    model.CreatedBy  = HttpContext.User.Identity.Name;
                    model.ModifiedOn = DateTime.Now;
                    model.ModifiedBy = HttpContext.User.Identity.Name;
                    db.BackupBeats.Add(model);
                }
                else
                {
                    var bp = db.BackupBeats.Find(model.Id);
                    bp.BeatId     = model.BeatId;
                    bp.ModifiedOn = DateTime.Now;
                    bp.ModifiedBy = HttpContext.User.Identity.Name;
                }

                db.SaveChanges();

                return(Json(true, JsonRequestBehavior.AllowGet));
            }
        }
Beispiel #9
0
        public ActionResult SaveOrder(MerchandiseOrder model)
        {
            bool retValue = true;

            if (model != null)
            {
                using (MTCDbContext db = new MTCDbContext())
                {
                    MerchandiseOrder order = db.MerchandiseOrders.Find(model.Id);
                    if (order != null)
                    {
                        AuditMerchandiseOrder(order);

                        order.ContactName   = model.ContactName;
                        order.ContactNumber = model.ContactNumber;
                        order.PickupDate    = model.PickupDate;
                        order.PickupTime    = model.PickupTime;
                        order.ReceivedBy    = model.ReceivedBy;
                        order.ReceivedOn    = model.ReceivedOn;
                        order.Comment       = model.Comment;

                        order.ModifiedBy = HttpContext.User.Identity.Name;
                        order.ModifiedOn = DateTime.Now;

                        db.SaveChanges();
                        SendEmails(order, true);
                    }
                }
            }

            return(Json(retValue, JsonRequestBehavior.AllowGet));
        }
Beispiel #10
0
        public async Task <ActionResult> ResolveTroubleTicketAdmin(int Id, DateTime firstShiftTruckMissed, DateTime lastShiftTruckMissed, String contractorNotes, String mtcNotes)
        {
            bool retValue = true;

            try
            {
                using (MTCDbContext db = new MTCDbContext())
                {
                    TroubleTicket troubleTicket = db.TroubleTickets.Find(Id);

                    if (troubleTicket != null)
                    {
                        this.AuditTroubleTicket(troubleTicket);

                        troubleTicket.FirstShiftTruckMissed = firstShiftTruckMissed;
                        troubleTicket.LastShiftTruckMissed  = lastShiftTruckMissed;
                        troubleTicket.ContractorNotes       = contractorNotes;
                        troubleTicket.MTCNotes            = mtcNotes;
                        troubleTicket.TroubleTicketStatus = TroubleTicketStatus.Resolved;
                        troubleTicket.ModifiedBy          = HttpContext.User.Identity.Name;
                        troubleTicket.ModifiedOn          = DateTime.Now;

                        await db.SaveChangesAsync();
                    }

                    this.EmailTicketResolution(troubleTicket, db);
                }
            }
            catch
            {
                retValue = false;
            }

            return(Json(retValue, JsonRequestBehavior.AllowGet));
        }
Beispiel #11
0
        public static string GetApplicationSettingValue(string applicationSettingVariableName)
        {
            var retvalue = string.Empty;

            try
            {
                if (!string.IsNullOrEmpty(applicationSettingVariableName))
                {
                    using (var db = new MTCDbContext())
                    {
                        if (db.MTCApplicationSettings.Any(p => p.Name == applicationSettingVariableName))
                        {
                            var mtcApplicationSetting = db.MTCApplicationSettings.FirstOrDefault(p => p.Name == applicationSettingVariableName);
                            if (mtcApplicationSetting != null)
                            {
                                retvalue = mtcApplicationSetting.Value;
                            }
                        }
                    }
                }
            }
            catch
            {
                // ignored
            }
            return(retvalue);
        }
Beispiel #12
0
        public ActionResult RemoveCustomSchedule(int id)
        {
            using (MTCDbContext db = new MTCDbContext())
            {
                var response = new TransactionResult();
                try
                {
                    BeatCustomSchedule beatCustomSchedules = db.BeatCustomSchedules.Find(id);
                    if (beatCustomSchedules != null)
                    {
                        db.BeatCustomSchedules.Remove(beatCustomSchedules);
                        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));
            }
        }
Beispiel #13
0
 private void AuditTroubleTicket(TroubleTicket troubleTicket)
 {
     using (MTCDbContext db = new MTCDbContext())
     {
         db.TroubleTicketAudits.Add(new TroubleTicketAudit(troubleTicket, DateTime.Now, HttpContext.User.Identity.Name));
         db.SaveChanges();
     }
 }
Beispiel #14
0
 public async Task <ActionResult> GetTroubleTicketLATATraxIssues()
 {
     using (MTCDbContext db = new MTCDbContext())
     {
         var data = db.TroubleTicketLATATraxIssues.OrderBy(p => p.Issue).ToList();
         return(Json(data, JsonRequestBehavior.AllowGet));
     }
 }
Beispiel #15
0
 private void AuditMerchandiseOrder(MerchandiseOrder order)
 {
     using (MTCDbContext db = new MTCDbContext())
     {
         db.MerchandiseOrderAudits.Add(new MerchandiseOrderAudit(order, DateTime.Now, HttpContext.User.Identity.Name));
         db.SaveChanges();
     }
 }
Beispiel #16
0
 public ActionResult GetCustomScheduleTimes(int customDateId)
 {
     using (MTCDbContext db = new MTCDbContext())
     {
         var data = db.CustomSchedules.Where(p => p.CustomDateId == customDateId).Select(p => new
         {
             Id   = p.Id,
             Name = p.ScheduleName
         }).ToList();
         return(Json(data, JsonRequestBehavior.AllowGet));
     }
 }
Beispiel #17
0
 public ActionResult GetBackupCancellationReasons()
 {
     using (var db = new MTCDbContext())
     {
         var data = from b in db.BackupCancellationReasons
                    select new
         {
             b.Id,
             Text = b.ReasonCode + " - " + b.Reason
         };
         return(Json(data.ToList(), JsonRequestBehavior.AllowGet));
     }
 }
Beispiel #18
0
        public ActionResult RemoveInvestigation(int id)
        {
            using (MTCDbContext db = new MTCDbContext())
            {
                Investigation investigation = db.Investigations.Find(id);
                if (investigation != null)
                {
                    db.Investigations.Remove(investigation);
                    db.SaveChanges();
                }

                return(Json(true, JsonRequestBehavior.AllowGet));
            }
        }
Beispiel #19
0
        public ActionResult RemoveBackupAssignment(int id)
        {
            using (var db = new MTCDbContext())
            {
                var bP = db.BackupAssignments.Find(id);
                if (bP == null)
                {
                    return(Json(false, JsonRequestBehavior.AllowGet));
                }
                db.BackupAssignments.Remove(bP);
                db.SaveChanges();

                return(Json(true, JsonRequestBehavior.AllowGet));
            }
        }
Beispiel #20
0
        public ActionResult GetAlarmTypes()
        {
            using (var dbc = new MTCDbContext())
            {
                var data = (from q in dbc.Violations
                            select new
                {
                    Id = q.AlarmName,
                    Text = q.AlarmName
                }).Where(a => a.Text != null).Distinct().OrderBy(AlarmName => AlarmName);
                ;

                return(Json(data.OrderBy(p => p.Text).ToList(), JsonRequestBehavior.AllowGet));
            }
        }
Beispiel #21
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));
            }
        }
Beispiel #22
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));
        }
Beispiel #23
0
        public ActionResult GetBackupAssignemtByBeat(Guid beatId)
        {
            using (var db = new MTCDbContext())
            {
                var contractors     = GetContractorList();
                var beats           = GetBeatList();
                var backupBeats     = db.BackupBeats.ToList();
                var backupProviders = db.BackupProviders.ToList();

                var data = db.BackupAssignments.Where(p => p.BeatId == beatId).ToList();

                var returnList = new List <BackupAssignmentViewModel>();
                foreach (var ba in data)
                {
                    var primaryBackupBeatId       = backupBeats.FirstOrDefault(t => t.Id == ba.PrimaryBackupBeatId)?.BeatId;
                    var primaryBackupContractorId = backupProviders.FirstOrDefault(c => c.BackupBeatId == ba.PrimaryBackupBeatId)?.ContractorId;

                    var secondaryBackupBeatId       = backupBeats.FirstOrDefault(t => t.Id == ba.SecondaryBackupBeatId)?.BeatId;
                    var secondaryBackupContractorId = backupProviders.FirstOrDefault(c => c.BackupBeatId == ba.SecondaryBackupBeatId)?.ContractorId;

                    var tertiaryBackupBeatId       = backupBeats.FirstOrDefault(t => t.Id == ba.TertiaryBackupBeatId)?.BeatId;
                    var tertiaryBackupContractorId = backupProviders.FirstOrDefault(c => c.BackupBeatId == ba.TertiaryBackupBeatId)?.ContractorId;

                    var m = new BackupAssignmentViewModel
                    {
                        Id                            = ba.Id,
                        BeatId                        = ba.BeatId,
                        BeatNumber                    = beats.FirstOrDefault(b => b.BeatId == ba.BeatId)?.BeatNumber,
                        PrimaryBackupBeatId           = ba.PrimaryBackupBeatId,
                        PrimaryBackupBeatNumber       = beats.FirstOrDefault(b => b.BeatId == primaryBackupBeatId)?.BeatNumber,
                        PrimaryBackupContractorId     = primaryBackupContractorId,
                        PrimaryBackupContractorName   = contractors.FirstOrDefault(p => p.ContractorId == primaryBackupContractorId)?.ContractorCompanyName,
                        SecondaryBackupBeatId         = ba.SecondaryBackupBeatId,
                        SecondaryBackupBeatNumber     = beats.FirstOrDefault(b => b.BeatId == secondaryBackupBeatId)?.BeatNumber,
                        SecondaryBackupContractorId   = secondaryBackupContractorId,
                        SecondaryBackupContractorName = contractors.FirstOrDefault(p => p.ContractorId == secondaryBackupContractorId)?.ContractorCompanyName,
                        TertiaryBackupBeatId          = ba.TertiaryBackupBeatId,
                        TertiaryBackupBeatNumber      = beats.FirstOrDefault(b => b.BeatId == tertiaryBackupBeatId)?.BeatNumber,
                        TertiaryBackupContractorId    = tertiaryBackupContractorId,
                        TertiaryBackupContractorName  = contractors.FirstOrDefault(p => p.ContractorId == tertiaryBackupContractorId)?.ContractorCompanyName
                    };
                    returnList.Add(m);
                }

                return(Json(returnList.FirstOrDefault(), JsonRequestBehavior.AllowGet));
            }
        }
Beispiel #24
0
        public ActionResult SaveViolation(ViolationViewModel model)
        {
            using (MTCDbContext db = new MTCDbContext())
            {
                Violation Violation = null;
                bool      isNew     = false;
                if (model.Id > 0)
                {
                    Violation = db.Violations.Find(model.Id);
                }
                else
                {
                    Violation           = new Violation();
                    Violation.CreatedOn = DateTime.Now;
                    Violation.CreatedBy = HttpContext.User.Identity.Name;
                    isNew = true;
                }

                Violation.ViolationTypeId     = model.ViolationTypeId;
                Violation.ContractorId        = model.ContractorId;
                Violation.DateTimeOfViolation = model.DateTimeOfViolation;

                Violation.BeatId                = model.BeatId;
                Violation.DriverId              = model.DriverId;
                Violation.FleetVehicleId        = model.FleetVehicleId;
                Violation.CallSign              = model.CallSign;
                Violation.OffenseNumber         = model.OffenseNumber;
                Violation.ViolationStatusTypeId = model.ViolationStatusTypeId;
                Violation.DeductionAmount       = model.DeductionAmount;
                Violation.Notes             = model.Notes;
                Violation.PenaltyForDriver  = model.PenaltyForDriver;
                Violation.LengthOfViolation = "0";

                Violation.ModifiedOn = DateTime.Now;
                Violation.ModifiedBy = HttpContext.User.Identity.Name;

                if (isNew)
                {
                    db.Violations.Add(Violation);
                }

                db.SaveChanges();

                return(Json(true, JsonRequestBehavior.AllowGet));
            }
        }
Beispiel #25
0
        public async Task <ActionResult> ReportRequest(UserReport userReport, bool?isImprovement)
        {
            if (ModelState.IsValid)
            {
                userReport.CreatedOn      = DateTime.UtcNow;
                userReport.CreatedBy      = HttpContext.User.Identity.Name;
                userReport.UserReportType = isImprovement == true ? UserReportType.Improvement : UserReportType.NewFeature;

                using (MTCDbContext db = new MTCDbContext())
                {
                    db.UserReports.Add(userReport);
                    await db.SaveChangesAsync();

                    return(RedirectToAction("ViewConfirmation", new { message = "Thank you! Your request has been processed." }));
                }
            }
            return(View("AboutReport"));
        }
Beispiel #26
0
        public async Task <ActionResult> Details(int?id)
        {
            using (MTCDbContext db = new MTCDbContext())
            {
                if (id == null)
                {
                    return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
                }

                TroubleTicket troubleTicket = await db.TroubleTickets.FindAsync(id);

                if (troubleTicket == null)
                {
                    return(HttpNotFound());
                }
                return(View(troubleTicket));
            }
        }
Beispiel #27
0
        public ActionResult GetCustomSchedules()
        {
            var beatCustomSchedules = new List <BeatCustomSchedule>();
            var CustomSchedules     = new List <CustomSchedule>();
            var CustomDates         = new List <CustomDate>();

            using (MTCDbContext dbb = new MTCDbContext())
            {
                beatCustomSchedules = dbb.BeatCustomSchedules.ToList();
                CustomSchedules     = dbb.CustomSchedules.ToList();
                CustomDates         = dbb.CustomDates.ToList();
            }

            using (MTCDBEntities db = new MTCDBEntities())
            {
                var data = from bhs in beatCustomSchedules
                           join hs in CustomSchedules on bhs.CustomScheduleId equals hs.Id
                           join h in CustomDates on hs.CustomDateId equals h.Id
                           join b in db.BeatDatas on bhs.BeatId equals b.ID
                           join cc in db.Contracts on b.ID equals cc.BeatId
                           join c in db.Contractors on cc.ContractorID equals c.ContractorID
                           select new
                {
                    Id                  = bhs.Id,
                    BeatId              = b.ID,
                    BeatNumber          = b.BeatName,
                    NumberOfTrucks      = bhs.NumberOfTrucks,
                    ContractorId        = c.ContractorID,
                    ContractCompanyName = c.ContractCompanyName,
                    ScheduleName        = hs.ScheduleName,
                    StartTime           = hs.StartTime,
                    //CustomDay = h.Abbreviation,
                    //CustomDateId = h.Id,
                    CustomDate       = h,
                    CustomScheduleId = hs.Id,
                    EndTime          = hs.EndTime,
                    StartDate        = cc.StartDate,
                    EndDate          = cc.EndDate,
                    BackupTruckCount = cc.BackupTruckCount
                };

                return(Json(data.OrderBy(p => p.ScheduleName).ToList(), JsonRequestBehavior.AllowGet));
            }
        }
Beispiel #28
0
 private void CheckInventoryLevels(int productId)
 {
     using (MTCDbContext db = new MTCDbContext())
     {
         var merchandiseInventoryNotificationThreshold = Utilities.GetApplicationSettingValue("MerchandiseInventoryNotificationThreshold");
         if (!string.IsNullOrEmpty(merchandiseInventoryNotificationThreshold))
         {
             var product = db.MerchandiseProducts.Find(productId);
             if (product != null)
             {
                 if (product.UnitsInStock < Convert.ToInt32(merchandiseInventoryNotificationThreshold))
                 {
                     //Send Email Notification
                     SendLowInventoryNotificationEmail(product);
                 }
             }
         }
     }
 }
Beispiel #29
0
        public ActionResult GetBackupBeats()
        {
            var beats = GetBeatList();

            using (var db = new MTCDbContext())
            {
                var data = db.BackupBeats.ToList().Select(p => new BackupBeatViewModel
                {
                    Id         = p.Id,
                    BeatId     = p.BeatId,
                    BeatNumber = beats.FirstOrDefault(b => b.BeatId == p.BeatId)?.BeatNumber,
                    CreatedBy  = p.CreatedBy,
                    CreatedOn  = p.CreatedOn,
                    ModifiedBy = p.ModifiedBy,
                    ModifiedOn = p.ModifiedOn
                });
                return(Json(data, JsonRequestBehavior.AllowGet));
            }
        }
Beispiel #30
0
        public ActionResult CancelBackupRequest(int Id, int cancellationReasonId, string comments)
        {
            using (var db = new MTCDbContext())
            {
                var br = db.BackupRequests.Find(Id);
                if (br == null)
                {
                    return(Json(false, JsonRequestBehavior.AllowGet));
                }

                br.IsCancelled = true;
                br.BackupCancellationReasonId = cancellationReasonId;
                br.CancellationComment        = comments;
                br.CancelledBy = HttpContext.User.Identity.Name;
                br.CancelledOn = DateTime.Now;
                db.SaveChanges();
            }
            return(Json(true, JsonRequestBehavior.AllowGet));
        }