예제 #1
0
        public IActionResult Index(int page, int pageSize, string search)
        {
            int countTotalRoutes = _routeServices.CountRoutes();
            PaginationViewModel <RouteViewModel> model = new PaginationViewModel <RouteViewModel>();

            if (page == 0)
            {
                page = 1;
            }
            if (pageSize == 0)
            {
                pageSize = model.PageSizeItem.Min();
            }
            model.Pager = new Pager(countTotalRoutes, page, pageSize);
            if (String.IsNullOrEmpty(search))
            {
                model.Items = _routeServices.GetAllRoutes(page, pageSize).ToList();
            }
            else
            {
                model.Items = _routeServices.GetAllRoutes(page, pageSize, search).ToList();
            }
            if (_locationServices.CountLocations() > 0)
            {
                ViewBag.Locations = _locationServices.GetAllLocations().ToList();
            }
            ViewBag.Search = search;
            return(View(model));
        }
        public async Task <IActionResult> Details(string transportId)
        {
            string message   = String.Empty;
            var    transInfo = await _transInfoServices.GetTransport(transportId);

            if (transInfo != null)
            {
                DetailTransInfoViewModel model = new DetailTransInfoViewModel()
                {
                    AdvanceMoney       = transInfo.AdvanceMoney,
                    CargoTonnage       = transInfo.CargoTonnage,
                    CargoTypes         = transInfo.CargoTypes,
                    DriverId           = transInfo.DayJob.DriverId,
                    IsCancel           = transInfo.IsCancel,
                    IsCompleted        = transInfo.IsCompleted,
                    Note               = transInfo.Note,
                    ReasonCancel       = transInfo.ReasonCancel,
                    ReturnOfAdvances   = transInfo.ReturnOfAdvances,
                    RouteId            = transInfo.RouteId,
                    TransportId        = transInfo.TransportId,
                    VehicleId          = transInfo.VehicleId,
                    DateCompletedLocal = transInfo.DateCompletedLocal,
                    DateStartLocal     = transInfo.DateStartLocal,
                    Drivers            = _userServices.GetDriverUsers().ToList(),
                    Routes             = _routeServices.GetAllRoutes().ToList(),
                    Vehicles           = (await _vehicleServices.GetAllVehicles()).ToList()
                };
                return(View(model));
            }
            message = "Lỗi không xác định, xin mời thao tác lại";
            TempData["UserMessage"] = SystemUtilites.SendSystemNotification(NotificationType.Error, message);
            return(RedirectToAction(actionName: "Manage"));
        }