Exemple #1
0
        public virtual DriverListModel PrepareListModel(DriverSearchModel searchModel)
        {
            if (null == searchModel)
            {
                throw new ArgumentNullException(nameof(searchModel));
            }

            var list = driverService.GetAll(
                pageIndex: searchModel.Page - 1,
                pageSize: searchModel.PageSize,
                name: searchModel.SearchName,
                enabled: searchModel.SearchEnabled);

            var model = new DriverListModel
            {
                Data = list.Select(x =>
                {
                    var modelItem = x.ToModel <DriverModel>();

                    return(modelItem);
                }),
                Total = list.TotalCount
            };

            return(model);
        }
Exemple #2
0
        public ActionResult Index(DriverListFiltersModel filters)
        {
            int pageTotal;

            var drivers = _driverService.GetAll("CreatedDate", "DESC", filters.Criteria, filters.Page, DefaultPageSize, out pageTotal);

            var pagedList = new StaticPagedList <DriverDto>(drivers, filters.Page, DefaultPageSize, pageTotal);

            var listModel = new DriverListModel(pagedList, filters);

            return(View(listModel));
        }
Exemple #3
0
        public List <DriverListModel> GetDriversList()
        {
            List <DriverListModel> _DriverList = new List <DriverListModel>();

            try
            {
                using (SqlConnection conn = new SqlConnection(DBConn))
                {
                    using (SqlCommand cmd = new SqlCommand($@"
                                  SELECT DISTINCT a.ID,max( a.PhoneNumber)PhoneNumber,max( a.FirstName)FirstName,max( a.LastName)LastName,
	max( a.MiddleName)MiddleName, max(a.Email)Email,max( Isnull(C.ShopName, 'NOT ASSIGNED'))  ShopName,
max(isnull(d.VehicleRegistration,'NOT ASSIGNED'))  VehicleRegistration
FROM Drivers as a
left join AssignShop as b on Convert(nvarchar(50), b.UserID) = Convert(nvarchar(50), a.ID)
left join Shops as c on c.ShopID = b.ShopsID
left join VehicleAssignmentHistory as e on e.DriverID = a.ID
left join Vehicles as d on d.ID = e.VehicleID group by a.ID", conn))//call Stored Procedure
                    {
                        cmd.CommandType = System.Data.CommandType.Text;
                        conn.Open();
                        SqlDataReader reader = cmd.ExecuteReader();
                        while (reader.Read())
                        {
                            DriverListModel _data = new DriverListModel()
                            {
                                ID                  = reader["ID"].ToString(),
                                PhoneNumber         = reader["PhoneNumber"].ToString(),
                                DriverName          = reader["FirstName"].ToString() + " " + reader["LastName"].ToString() + " " + reader["MiddleName"].ToString(),
                                Email               = reader["Email"].ToString(),
                                ShopName            = reader["ShopName"].ToString(),
                                VehicleRegistration = reader["VehicleRegistration"].ToString()
                            };
                            _DriverList.Add(_data);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
            }

            return(_DriverList);
        }
Exemple #4
0
        public async Task <IActionResult> GetListDrivers()
        {
            //get user Id
            var userId = User.FindFirst(AppClaims.UserId)?.Value;

            //query database for list of drivers associated with current driver
            var drivers = await _context.Sponsors
                          .Where(x => x.AppUserId == userId)
                          .SelectMany(x => x.Drivers)
                          .ToListAsync();

            //create new model and populate it
            var model = new DriverListModel
            {
                DriverIds = drivers.Select(x => x.AppUserId).ToList()
            };

            //return list of current drivers for current sponsor
            return(Ok(model));
        }