Esempio n. 1
0
        public CallHistoryListModel FilterHistory(int groupId, int userId, string handoverDate, string callDate, int statusMapId, int statusCareId, string levelIds, string mobilePhone, int employeeTypeId, int page, int rows)
        {
            string users;

            if (userId == 0)
            {
                if (groupId == 0)
                {
                    users = string.Empty;
                }
                else
                {
                    users = StoreData.ListUser
                            .Where(c => c.GroupId == groupId)
                            .Select(c => c.UserID.ToString())
                            .Distinct().Aggregate((total, curent) => total + "," + curent);
                }
            }
            else
            {
                users = userId.ToString();
            }
            var employeeType = (EmployeeType)employeeTypeId;
            var dateCall     = callDate.IsStringNullOrEmpty() ? null : callDate.ToDateTime();
            var dateHandover = handoverDate.IsStringNullOrEmpty() ? null : handoverDate.ToDateTime();

            int totalRecords;
            var model = new CallHistoryListModel
            {
                Rows     = CallHistoryRepository.FilterHistory(users, dateHandover, dateCall, statusMapId, statusCareId, levelIds, mobilePhone, employeeType, page, rows, out totalRecords),
                Total    = (totalRecords / rows) + 1,
                UserData = new List <string>
                {
                    totalRecords.ToString(),
                },
                Records = rows,
                Page    = page,
            };

            return(model);
        }