Exemplo n.º 1
0
        /// <summary>
        /// Get paged list of client as per client id and pageinfo object
        /// </summary>
        /// <param name="pagingInfo">pagingInfo object</param>
        /// <param name="ClientId">Id of the client</param>
        /// <returns>Returns paged list of the user</returns>
        public static PageData <UserDTO> GetUserPagedListbyClientId(PagingInfo pagingInfo, int ClientId)
        {
            List <UserDTO>     UserDTOList = new List <UserDTO>();
            PageData <UserDTO> pageList    = new PageData <UserDTO>();

            if (pagingInfo == null)
            {
                PagingInfo PagingInfoCreated = new PagingInfo();
                PagingInfoCreated.Page         = 1;
                PagingInfoCreated.Reverse      = false;
                PagingInfoCreated.ItemsPerPage = 1;
                PagingInfoCreated.Search       = "";
                PagingInfoCreated.TotalItem    = 0;

                pagingInfo = PagingInfoCreated;
            }

            UserDTOList = GetUsersbyClientId(ClientId, pagingInfo.Search);
            IQueryable <UserDTO> UserDTOPagedList = UserDTOList.AsQueryable();

            ////Sorting
            //ClientUserDTOPagedList = PagingService.Sorting<ClientUserDTO>(ClientUserDTOPagedList, pagingInfo.SortBy, pagingInfo.Reverse);

            // paging
            if (UserDTOPagedList.Count() > 0)
            {
                var ContacDTOPerPage = PagingService.Paging <UserDTO>(UserDTOPagedList, pagingInfo.ItemsPerPage, pagingInfo.Page);
                pageList.Count = UserDTOPagedList.Count();

                pageList.SuccessCount = GetActiveUserCount(ClientId);
                pageList.FailureCount = GetInactiveUserCount(ClientId);

                List <UserDTO> pagedClientUserDTOList = new List <UserDTO>();
                foreach (var item in ContacDTOPerPage)
                {
                    pagedClientUserDTOList.Add(item);
                }
                pageList.Data = pagedClientUserDTOList;
            }
            else
            {
                pageList.Data = null;
            }



            return(pageList);
        }
        //Get template client wise list by client id and search criteria
        public static List <TemplateDTO> GetTemplatesbyClientId(int ClientId, string search, PagingInfo pagingInfo)
        {
            List <TemplateDTO> templateDTO = new List <TemplateDTO>();

            try
            {
                UnitOfWork            uow       = new UnitOfWork();
                int                   skip      = (pagingInfo.Page - 1) * pagingInfo.ItemsPerPage;
                int                   take      = pagingInfo.ItemsPerPage;
                IQueryable <Template> Templates = uow.TemplateRepo.GetAll().Where(e => e.ClientId == ClientId).AsQueryable();//.OrderBy(e => e.Title).Skip(skip).Take(take).ToList();
                Templates = PagingService.Sorting <Template>(Templates, pagingInfo.SortBy, pagingInfo.Reverse);
                var Template = Templates.Skip(skip).Take(take).ToList();

                if (Template != null)
                {
                    if (search != "" && search != null)
                    {
                        bool IsDate = CommonService.IsDate(search);
                        if (IsDate != true)
                        {
                            // string search
                            IQueryable <Template> Templatesearchs = uow.TemplateRepo.GetAll().Where(e => (e.Title.ToLower().Contains(search.ToLower()) || e.Message.ToLower().Contains(search.ToLower())) && e.ClientId == ClientId).AsQueryable();//.OrderBy(e => e.Title).Skip(skip).Take(take);
                            Templatesearchs = PagingService.Sorting <Template>(Templatesearchs, pagingInfo.SortBy, pagingInfo.Reverse);
                            var Templatesearch = Templatesearchs.Skip(skip).Take(take).ToList();

                            if (Templatesearch != null)
                            {
                                foreach (var item in Templatesearch)
                                {
                                    templateDTO.Add(Transform.TemplateToDTO(item));
                                }
                            }
                            return(templateDTO);
                        }
                        else
                        {
                            ////date wise search
                            //DateTime date = Convert.ToDateTime(search);
                            //var Templatesearch = Template.Where(e => e.AnniversaryDate >= date && e.AnniversaryDate < date.AddDays(1) || e.BirthDate >= date && e.BirthDate < date.AddDays(1));

                            //if (Templatesearch != null)
                            //{
                            //    foreach (var item in Templatesearch)
                            //    {
                            //        templateDTO.Add(Transform.TemplateToDTO(item));
                            //    }
                            //}
                            //return templateDTO;
                        }
                    }
                    else
                    {
                        foreach (var item in Template)
                        {
                            templateDTO.Add(Transform.TemplateToDTO(item));
                        }
                    }
                }

                return(templateDTO);
            }
            catch (Exception)
            {
                throw;
            }
        }
        //Get client list with active or inactive status by partner
        public static List <ClientDTO> GetClientsbyPartnerIdWithIsActive(int PartnerId, string search, bool IsActive, PagingInfo pagingInfo)
        {
            List <ClientDTO> ClientDTO = new List <ClientDTO>();

            //List<PartnerDTO> PartnerDTO = new List<PartnerDTO>();

            try
            {
                UnitOfWork uow  = new UnitOfWork();
                int        skip = (pagingInfo.Page - 1) * pagingInfo.ItemsPerPage;
                int        take = pagingInfo.ItemsPerPage;

                IQueryable <Client> Client = uow.ClientRepo.GetAll().Where(e => e.PartnerId == PartnerId && e.IsActive == IsActive).ToList().AsQueryable();//.OrderBy(e => e.Company);
                Client = PagingService.Sorting <Client>(Client, pagingInfo.SortBy, pagingInfo.Reverse);
                Client = Client.Skip(skip).Take(take);

                List <ClientDTO> ClientDTOList = new List <ClientDTO>();

                if (Client != null)
                {
                    foreach (var item in Client)
                    {
                        ClientDTOList.Add(Transform.ClientToDTO(item));
                    }
                }

                if (ClientDTOList != null)
                {
                    if (search != "" && search != null)
                    {
                        bool IsDate = CommonService.IsDate(search);
                        if (IsDate != true)
                        {
                            IQueryable <Client> Clientsearch = uow.ClientRepo.GetAll().Where(e => (e.Address != null ? (e.Address.ToLower().Contains(search.ToLower())) : false) || e.Company.ToLower().Contains(search.ToLower()) || (e.AlertCreditBalanceLimit.ToString() != null ? (e.AlertCreditBalanceLimit.ToString().Contains(search.ToString())) : false) || e.SMSCredit.ToString().Contains(search) || (e.RegisteredDate.ToString() != null ? (Convert.ToDateTime(e.RegisteredDate).ToString("dd-MMM-yyyy").ToLower().Contains(pagingInfo.Search.ToLower())) : false) && e.IsActive == IsActive).AsQueryable();//.OrderBy(e => e.Company);
                            Clientsearch = PagingService.Sorting <Client>(Clientsearch, pagingInfo.SortBy, pagingInfo.Reverse);
                            Clientsearch = Clientsearch.Skip(skip).Take(take);

                            if (Clientsearch != null)
                            {
                                foreach (var item in Clientsearch)
                                {
                                    ClientDTO.Add(Transform.ClientToDTO(item));
                                }
                            }
                            return(ClientDTO.Skip(skip).Take(take).ToList());
                        }
                        else
                        {
                            //date wise search
                            DateTime            date         = Convert.ToDateTime(search);
                            IQueryable <Client> Clientsearch = uow.ClientRepo.GetAll().Where(e => e.RegisteredDate >= date && e.RegisteredDate < date.AddDays(1) && e.IsActive == IsActive).AsQueryable();//.OrderBy(e => e.Company);
                            Clientsearch = PagingService.Sorting <Client>(Clientsearch, pagingInfo.SortBy, pagingInfo.Reverse);
                            Clientsearch = Clientsearch.Skip(skip).Take(take);
                            if (Clientsearch != null)
                            {
                                foreach (var item in Clientsearch)
                                {
                                    ClientDTO.Add(Transform.ClientToDTO(item));
                                }
                            }
                            return(ClientDTO.Skip(skip).Take(take).ToList());
                        }
                    }
                    else
                    {
                        foreach (var item in ClientDTOList)
                        {
                            ClientDTO.Add(item);
                        }
                        return(ClientDTO.Skip(skip).Take(take).ToList());
                    }
                }

                return(ClientDTOList);
            }
            catch (Exception)
            {
                throw;
            }
        }
Exemplo n.º 4
0
        //Get present contact count as per group id
        public static int GetGroupIdWisePresentContactsCount(PagingInfo pagingInfo)
        {
            List <GroupContactDTO> GroupContactDTOList = new List <GroupContactDTO>();
            List <ContactDTO>      ContactDTOList      = new List <ContactDTO>();

            List <Contact> ContactList = new List <Contact>();

            try
            {
                int skip = (pagingInfo.Page - 1) * pagingInfo.ItemsPerPage;
                int take = pagingInfo.ItemsPerPage;

                UnitOfWork uow = new UnitOfWork();
                IQueryable <GroupContact> GroupContact = uow.GroupContactRepo.GetAll().Where(e => e.GroupId == pagingInfo.GroupId).AsQueryable();
                //GroupContact = PagingService.Sorting<GroupContact>(GroupContact, pagingInfo.SortBy, pagingInfo.Reverse);

                if (GroupContact != null)
                {
                    //foreach (var item in GroupContact)
                    //{
                    //    Contact Contact = new Contact();
                    //    Contact = uow.ContactRepo.GetById(item.ContactId);
                    //    ContactList.Add(Contact);
                    //}

                    if (ContactList != null)
                    {
                        if (pagingInfo.Search != "" && pagingInfo.Search != null)
                        {
                            List <ContactDTO> ContactDTOSearchList = new List <ContactDTO>();

                            bool IsDate = CommonService.IsDate(pagingInfo.Search);
                            if (IsDate != true)
                            {
                                // string search

                                IQueryable <Contact> Contactsearch = ContactList.Where(e => (e.Email != null ? (e.Email.ToLower().Contains(pagingInfo.Search.ToLower())) : false) || e.MobileNumber.Contains(pagingInfo.Search) || (e.Name != null ? (e.Name.ToLower().Contains(pagingInfo.Search.ToLower())) : false) || (e.FirstName != null ? (e.FirstName.ToLower().Contains(pagingInfo.Search.ToLower())) : false) || (e.LastName != null ? (e.LastName.ToLower().Contains(pagingInfo.Search.ToLower())) : false) || (e.AnniversaryDate.ToString() != null ? (Convert.ToDateTime(e.AnniversaryDate).ToString("dd-MMM-yyyy").ToLower().Contains(pagingInfo.Search.ToLower())) : false) || (e.BirthDate.ToString() != null ? (Convert.ToDateTime(e.BirthDate).ToString("dd-MMM-yyyy").ToLower().Contains(pagingInfo.Search.ToLower())) : false)).AsQueryable();//.OrderBy(e => e.Name);
                                Contactsearch = PagingService.Sorting <Contact>(Contactsearch, pagingInfo.SortBy, pagingInfo.Reverse);

                                if (Contactsearch != null)
                                {
                                    return(Contactsearch.Count());
                                }
                            }
                            else
                            {
                                //date wise search
                                DateTime             date          = Convert.ToDateTime(pagingInfo.Search);
                                IQueryable <Contact> Contactsearch = ContactList.Where(e => e.AnniversaryDate >= date && e.AnniversaryDate < date.AddDays(1) || e.BirthDate >= date && e.BirthDate < date.AddDays(1)).AsQueryable();//.OrderBy(e => e.Name);
                                Contactsearch = PagingService.Sorting <Contact>(Contactsearch, pagingInfo.SortBy, pagingInfo.Reverse);
                                if (Contactsearch != null)
                                {
                                    return(Contactsearch.Count());
                                }
                            }
                        }
                    }
                    return(GroupContact.Count());
                }


                return(GroupContact.Count());
            }
            catch (Exception)
            {
                throw;
            }
        }
Exemplo n.º 5
0
        //Get contact paged list by client id
        public static PageData <ContactDTO> GetContactPagedListbyClientId(PagingInfo pagingInfo)
        {
            List <ContactDTO>     ContactDTOList = new List <ContactDTO>();
            PageData <ContactDTO> pageList       = new PageData <ContactDTO>();

            if (pagingInfo == null)
            {
                PagingInfo PagingInfoCreated = new PagingInfo();
                PagingInfoCreated.Page         = 1;
                PagingInfoCreated.Reverse      = false;
                PagingInfoCreated.ItemsPerPage = 1;
                PagingInfoCreated.Search       = "";
                PagingInfoCreated.TotalItem    = 0;
                PagingInfoCreated.GroupId      = 0;
                pagingInfo = PagingInfoCreated;
            }

            if (pagingInfo.SortBy == "")
            {
                pagingInfo.SortBy = "Name";
            }



            ContactDTOList = GetGroupIdWisePresentContacts(pagingInfo);


            UnitOfWork uow = new UnitOfWork();
            IQueryable <ContactDTO> ContactDTOPagedList = ContactDTOList.AsQueryable();
            int count = 0;

            if (pagingInfo.Search != "" && pagingInfo.Search != null)
            {
                bool IsDate = CommonService.IsDate(pagingInfo.Search);
                if (IsDate != true)
                {
                    count = 0;
                    count = GetGroupIdWisePresentContactsCount(pagingInfo);
                }
                else
                {
                    DateTime date = Convert.ToDateTime(pagingInfo.Search);
                    count = 0;
                    count = GetGroupIdWisePresentContactsCount(pagingInfo);
                }
            }
            else
            {
                count = GetGroupIdWisePresentContactsCount(pagingInfo);
            }


            ////Sorting
            ContactDTOPagedList = PagingService.Sorting <ContactDTO>(ContactDTOPagedList, pagingInfo.SortBy, pagingInfo.Reverse);

            // paging
            if (ContactDTOPagedList.Count() > 0)
            {
                // var ContacDTOPerPage = PagingService.Paging<ContactDTO>(ContactDTOPagedList, pagingInfo.ItemsPerPage, pagingInfo.Page);
                pageList.Count = count;

                List <ContactDTO> pagedContactDTOList = new List <ContactDTO>();
                foreach (var item in ContactDTOPagedList)
                {
                    pagedContactDTOList.Add(item);
                }
                pageList.Data = pagedContactDTOList;
            }
            else
            {
                pageList.Data = null;
            }



            return(pageList);
        }
Exemplo n.º 6
0
        //Get contact present list as per group id
        public static List <ContactDTO> GetGroupIdWisePresentContacts(PagingInfo pagingInfo)
        {
            List <GroupContactDTO> GroupContactDTOList = new List <GroupContactDTO>();
            List <ContactDTO>      ContactDTOList      = new List <ContactDTO>();
            List <Contact>         ContactList         = new List <Contact>();

            int ClientId = 0;

            if (pagingInfo.GroupId != 0)
            {
                ClientId = GroupService.GetById(pagingInfo.GroupId).ClientID;
            }

            try
            {
                int skip = (pagingInfo.Page - 1) * pagingInfo.ItemsPerPage;
                int take = pagingInfo.ItemsPerPage;

                // string search
                //string ContactIdStringall = ContactService.GetContactIdarrayByName(pagingInfo.Search, ClientId);

                UnitOfWork uow = new UnitOfWork();
                IQueryable <GroupContact> GroupContact = uow.GroupContactRepo.GetAll().Where(e => e.GroupId == pagingInfo.GroupId).AsQueryable(); //&& (ContactIdStringall != null ? (e.ContactId.ToString().Split(',').Any(ContactId => ContactIdStringall.Contains(ContactId.ToString()))) : false)
                //GroupContact = PagingService.Sorting<GroupContact>(GroupContact, pagingInfo.SortBy, pagingInfo.Reverse);
                GroupContact = GroupContact.Skip(skip).Take(take);
                if (GroupContact != null)
                {
                    foreach (var item in GroupContact)
                    {
                        Contact Contact = new Contact();
                        Contact = uow.ContactRepo.GetById(item.ContactId);
                        ContactList.Add(Contact);
                        //ContactDTO ContactDTO = new ContactDTO();
                        //ContactDTO = ContactService.GetById(item.ContactId);
                        //ContactDTOList.Add(ContactDTO);
                    }

                    if (ContactList != null)
                    {
                        if (pagingInfo.Search != "" && pagingInfo.Search != null)
                        {
                            List <ContactDTO> ContactDTOSearchList = new List <ContactDTO>();

                            bool IsDate = CommonService.IsDate(pagingInfo.Search);
                            if (IsDate != true)
                            {
                                // string search
                                string ContactIdString = ContactService.GetContactIdarrayByName(pagingInfo.Search, ClientId);
                                IQueryable <GroupContact> GroupContactSearch = uow.GroupContactRepo.GetAll().Where(e => e.GroupId == pagingInfo.GroupId && (ContactIdString != null ? (e.ContactId.ToString().Split(',').Any(ContactId => ContactIdString.Contains(ContactId.ToString()))) : false)).AsQueryable();
                                //GroupContact = PagingService.Sorting<GroupContact>(GroupContact, pagingInfo.SortBy, pagingInfo.Reverse);
                                GroupContactSearch = GroupContactSearch.Skip(skip).Take(take);
                                if (GroupContactSearch != null)
                                {
                                    List <Contact> ContactListSearch = new List <Contact>();
                                    foreach (var item in GroupContactSearch)
                                    {
                                        Contact Contact = new Contact();
                                        Contact = uow.ContactRepo.GetById(item.ContactId);
                                        ContactListSearch.Add(Contact);
                                    }

                                    IQueryable <Contact> Contactsearch = ContactListSearch.Where(e => (e.Email != null ? (e.Email.ToLower().Contains(pagingInfo.Search.ToLower())) : false) || e.MobileNumber.Contains(pagingInfo.Search) || (e.Name != null ? (e.Name.ToLower().Contains(pagingInfo.Search.ToLower())) : false) || (e.FirstName != null ? (e.FirstName.ToLower().Contains(pagingInfo.Search.ToLower())) : false) || (e.LastName != null ? (e.LastName.ToLower().Contains(pagingInfo.Search.ToLower())) : false) || (e.AnniversaryDate.ToString() != null ? (Convert.ToDateTime(e.AnniversaryDate).ToString("dd-MMM-yyyy").ToLower().Contains(pagingInfo.Search.ToLower())) : false) || (e.BirthDate.ToString() != null ? (Convert.ToDateTime(e.BirthDate).ToString("dd-MMM-yyyy").ToLower().Contains(pagingInfo.Search.ToLower())) : false)).AsQueryable();//.OrderBy(e => e.Name);
                                    Contactsearch = PagingService.Sorting <Contact>(Contactsearch, pagingInfo.SortBy, pagingInfo.Reverse);
                                    Contactsearch = Contactsearch.Skip(skip).Take(take);
                                    if (Contactsearch != null)
                                    {
                                        foreach (var item in Contactsearch)
                                        {
                                            ContactDTOSearchList.Add(Transform.ContactToDTO(item));
                                        }
                                    }
                                    return(ContactDTOSearchList.Skip(skip).Take(take).ToList());
                                }
                            }
                            else
                            {
                                //date wise search
                                string ContactIdString = ContactService.GetContactIdarrayByName(pagingInfo.Search, ClientId);

                                IQueryable <GroupContact> GroupContactSearch = uow.GroupContactRepo.GetAll().Where(e => e.GroupId == pagingInfo.GroupId && (ContactIdString != null ? (e.ContactId.ToString().Split(',').Any(ContactId => ContactIdString.Contains(ContactId.ToString()))) : false)).AsQueryable();
                                //GroupContact = PagingService.Sorting<GroupContact>(GroupContact, pagingInfo.SortBy, pagingInfo.Reverse);
                                GroupContactSearch = GroupContactSearch.Skip(skip).Take(take);
                                if (GroupContactSearch != null)
                                {
                                    List <Contact> ContactListSearch = new List <Contact>();
                                    foreach (var item in GroupContactSearch)
                                    {
                                        Contact Contact = new Contact();
                                        Contact = uow.ContactRepo.GetById(item.ContactId);
                                        ContactListSearch.Add(Contact);
                                    }


                                    DateTime             date          = Convert.ToDateTime(pagingInfo.Search);
                                    IQueryable <Contact> Contactsearch = ContactListSearch.Where(e => e.AnniversaryDate >= date && e.AnniversaryDate < date.AddDays(1) || e.BirthDate >= date && e.BirthDate < date.AddDays(1)).AsQueryable();//.OrderBy(e => e.Name);
                                    Contactsearch = PagingService.Sorting <Contact>(Contactsearch, pagingInfo.SortBy, pagingInfo.Reverse);
                                    Contactsearch = Contactsearch.Skip(skip).Take(take);
                                    if (Contactsearch != null)
                                    {
                                        foreach (var item in Contactsearch)
                                        {
                                            ContactDTOSearchList.Add(Transform.ContactToDTO(item));
                                        }
                                    }
                                    return(ContactDTOSearchList.Skip(skip).Take(take).ToList());
                                }
                            }
                        }

                        //ContactList = ContactList.Skip(skip).Take(take).ToList();
                        foreach (var item in ContactList)
                        {
                            ContactDTOList.Add(Transform.ContactToDTO(item));
                        }
                    }


                    return(ContactDTOList);// ContactDTOList.Skip(skip).Take(take).ToList();
                }


                return(ContactDTOList.Skip(skip).Take(take).ToList());
            }
            catch (Exception)
            {
                throw;
            }
        }
Exemplo n.º 7
0
        /// <summary>
        /// Get paged list of active or inactive user by Client id
        /// </summary>
        /// <param name="pagingInfo">pagingInfo object</param>
        /// <param name="ClientId">Id of the client</param>
        /// <param name="IsActive">TRUE OR False</param>
        /// <returns>Returns Active or Inactive user's paged list </returns>
        public static PageData <UserDTO> GetUserPagedListbyClientIdWithIsActive(PagingInfo pagingInfo, int ClientId, bool IsActive)
        {
            List <UserDTO>     UserDTOList = new List <UserDTO>();
            PageData <UserDTO> pageList    = new PageData <UserDTO>();

            if (pagingInfo == null)
            {
                PagingInfo PagingInfoCreated = new PagingInfo();
                PagingInfoCreated.Page         = 1;
                PagingInfoCreated.Reverse      = false;
                PagingInfoCreated.ItemsPerPage = 1;
                PagingInfoCreated.Search       = "";
                PagingInfoCreated.TotalItem    = 0;

                pagingInfo = PagingInfoCreated;
            }

            if (pagingInfo.SortBy == "")
            {
                pagingInfo.SortBy = "Name";
            }


            UserDTOList = GetUsersbyClientIdWithIsActive(ClientId, pagingInfo.Search, IsActive, pagingInfo);
            IQueryable <UserDTO> UserDTOPagedList = UserDTOList.AsQueryable();

            UnitOfWork uow   = new UnitOfWork();
            int        count = 0;

            if (pagingInfo.Search != "" && pagingInfo.Search != null)
            {
                bool IsDate = CommonService.IsDate(pagingInfo.Search);
                if (IsDate != true)
                {
                    //int LocationId = LocationService.GetByLocationName(pagingInfo.Search, ClientId);
                    string LocationIdString = LocationService.GetLocationIdarrayByName(pagingInfo.Search, ClientId);
                    count = 0;
                    count = uow.UserRepo.GetAll().Where(e => (e.Email.ToLower().Contains(pagingInfo.Search.ToLower()) || e.Name.ToLower().Contains(pagingInfo.Search.ToLower()) || (e.Mobile != null ? (e.Mobile.Contains(pagingInfo.Search)) : false) || (LocationIdString != null ? (e.LocationId.ToString().Split(',').Any(LocationId => LocationIdString.Contains(LocationId))) : false)) && e.IsActive == IsActive && e.ClientId == ClientId).OrderBy(e => e.Name).Count();
                }
                else
                {
                    //DateTime date = Convert.ToDateTime(pagingInfo.Search);
                    //count = 0;
                    //count = uow.UserRepo.GetAll().Where(e => e.CreatedDate >= date && e.CreatedDate < date.AddDays(1) || e.ScheduledDate >= date && e.ScheduledDate < date.AddDays(1)).OrderByDescending(e => e.CreatedDate).Count();
                }
            }
            else
            {
                count = uow.UserRepo.GetAll().Where(e => e.ClientId == ClientId && e.IsActive == IsActive).Count();
            }

            ////Sorting
            UserDTOPagedList = PagingService.Sorting <UserDTO>(UserDTOPagedList, pagingInfo.SortBy, pagingInfo.Reverse);

            // paging
            if (UserDTOPagedList.Count() > 0)
            {
                //var ContacDTOPerPage = PagingService.Paging<UserDTO>(UserDTOPagedList, pagingInfo.ItemsPerPage, pagingInfo.Page);
                pageList.Count = count;// UserDTOPagedList.Count();

                pageList.SuccessCount = GetActiveUserCount(ClientId);
                pageList.FailureCount = GetInactiveUserCount(ClientId);


                List <UserDTO> pagedClientUserDTOList = new List <UserDTO>();
                foreach (var item in UserDTOPagedList)
                {
                    pagedClientUserDTOList.Add(item);
                }
                pageList.Data = pagedClientUserDTOList;
            }
            else
            {
                pageList.Data = null;
            }



            return(pageList);
        }
Exemplo n.º 8
0
        /// <summary>
        /// Get active or inactive Users by Client id
        /// </summary>
        /// <param name="ClientId">Id of the Client</param>
        /// <param name="search">search string</param>
        /// <param name="IsActive">TRUE OR FALSE</param>
        /// <param name="pagingInfo">pagingInfo object</param>
        /// <returns> Returns Active or Inactive user list </returns>
        public static List <UserDTO> GetUsersbyClientIdWithIsActive(int ClientId, string search, bool IsActive, PagingInfo pagingInfo)
        {
            List <UserDTO> UserDTOList = new List <UserDTO>();

            try
            {
                UnitOfWork uow = new UnitOfWork();

                int skip = (pagingInfo.Page - 1) * pagingInfo.ItemsPerPage;
                int take = pagingInfo.ItemsPerPage;

                IQueryable <User> User = uow.UserRepo.GetAll().Where(e => e.ClientId == ClientId && e.IsActive == IsActive).OrderBy(e => e.Name).AsQueryable();// .ToList().Skip(skip).Take(take);
                User = PagingService.Sorting <User>(User, pagingInfo.SortBy, pagingInfo.Reverse);
                User = User.Skip(skip).Take(take);


                if (User != null)
                {
                    foreach (var user in User)
                    {
                        UserDTO UserDTO = new UserDTO();
                        UserDTO = Transform.UserToDTO(user);
                        LocationDTO LocationDTO = new LocationDTO();
                        UserDTO.Location = LocationService.GetById(UserDTO.LocationId).Name;
                        UserDTOList.Add(UserDTO);
                    }

                    if (search != "" && search != null)
                    {
                        //int LocationId = LocationService.GetByLocationName(search, ClientId);
                        string LocationIdString = LocationService.GetLocationIdarrayByName(search, ClientId);

                        bool IsDate = CommonService.IsDate(search);
                        if (IsDate != true)
                        {
                            // string search
                            List <UserDTO>    UserDTOListSearch = new List <UserDTO>();
                            IQueryable <User> UserSearch        = uow.UserRepo.GetAll().Where(e => (e.Email.ToLower().Contains(search.ToLower()) || e.Name.ToLower().Contains(search.ToLower()) || e.FirstName.ToLower().Contains(search.ToLower()) || e.LastName.ToLower().Contains(search.ToLower()) || (e.Mobile != null ? (e.Mobile.Contains(search)) : false) || (LocationIdString != null ? (e.LocationId.ToString().Split(',').Any(LocationId => LocationIdString.Contains(LocationId.ToString()))) : false)) && e.IsActive == IsActive && e.ClientId == ClientId).AsQueryable();//.OrderBy(e => e.Name).ToList().Skip(skip).Take(take); //(e.Location != null ? (e.Location.ToLower().Contains(search.ToLower())) : false)
                            UserSearch = PagingService.Sorting <User>(UserSearch, pagingInfo.SortBy, pagingInfo.Reverse);
                            UserSearch = UserSearch.Skip(skip).Take(take);

                            foreach (var user in UserSearch)
                            {
                                UserDTO UserDTO = new UserDTO();
                                UserDTO = Transform.UserToDTO(user);
                                LocationDTO LocationDTO = new LocationDTO();
                                UserDTO.Location = LocationService.GetById(UserDTO.LocationId).Name;
                                UserDTOListSearch.Add(UserDTO);
                            }
                            return(UserDTOListSearch);
                        }
                        else
                        {
                        }
                    }
                    ////else
                    ////{
                    ////    ////foreach (var item in User)
                    ////    ////{
                    ////    ////    //UserDTO UserDTO = new UserDTO();
                    ////    ////    UserDTOList.Add(Transform.UserToDTO(item));
                    ////    ////}
                    ////}
                }

                return(UserDTOList);
            }
            catch (Exception)
            {
                throw;
            }
        }
Exemplo n.º 9
0
        //Get plan paged list
        public static PageData <PlanDTO> GetPlanPagedList(PagingInfo pagingInfo)
        {
            List <PlanDTO>     PlanDTOList = new List <PlanDTO>();
            PageData <PlanDTO> pageList    = new PageData <PlanDTO>();

            if (pagingInfo == null)
            {
                PagingInfo PagingInfoCreated = new PagingInfo();
                PagingInfoCreated.Page         = 1;
                PagingInfoCreated.Reverse      = false;
                PagingInfoCreated.ItemsPerPage = 1;
                PagingInfoCreated.Search       = "";
                PagingInfoCreated.TotalItem    = 0;

                pagingInfo = PagingInfoCreated;
            }
            if (pagingInfo.SortBy == "")
            {
                pagingInfo.SortBy = "Title";
            }

            PlanDTOList = GetPlanList(pagingInfo);

            IQueryable <PlanDTO> PlanDTOPagedList = PlanDTOList.AsQueryable();

            UnitOfWork uow   = new UnitOfWork();
            int        count = 0;

            if (pagingInfo.Search != "" && pagingInfo.Search != null)
            {
                bool IsDate = CommonService.IsDate(pagingInfo.Search);
                if (IsDate != true)
                {
                    count = 0;
                    count = uow.PlanRepo.GetAll().Where(e => (e.Title != null ? (e.Title.ToLower().Contains(pagingInfo.Search.ToLower())) : false) || e.Price.ToString().ToLower().Contains(pagingInfo.Search.ToLower()) || (e.Min.ToString() != null ? (e.Min.ToString().Contains(pagingInfo.Search.ToString())) : false) || e.Max.ToString().Contains(pagingInfo.Search) || (e.Tax.ToString() != null ? (e.Tax.ToString().ToLower().Contains(pagingInfo.Search.ToLower())) : false)).Count();//|| e.IsEcoupon.ToString().Contains(pagingInfo.Search)  //.OrderBy(e => e.Company);
                }
                else
                {
                    //DateTime date = Convert.ToDateTime(pagingInfo.Search);
                    //count = 0;
                    //count = uow.ClientRepo.GetAll().Where(e => e.RegisteredDate >= date && e.RegisteredDate < date.AddDays(1) && e.IsActive == IsActive && e.PartnerId == PartnerId).Count();
                }
            }
            else
            {
                count = uow.PlanRepo.GetAll().Count();
            }

            ////Sorting
            PlanDTOPagedList = PagingService.Sorting <PlanDTO>(PlanDTOPagedList, pagingInfo.SortBy, pagingInfo.Reverse);

            // paging
            if (PlanDTOPagedList.Count() > 0)
            {
                //var ContacDTOPerPage = PagingService.Paging<ClientDTO>(ClientDTOPagedList, pagingInfo.ItemsPerPage, pagingInfo.Page);
                pageList.Count = count;// ClientDTOPagedList.Count();


                List <PlanDTO> pagedPlanDTOList = new List <PlanDTO>();
                foreach (var item in PlanDTOPagedList)
                {
                    pagedPlanDTOList.Add(item);
                }
                pageList.Data = pagedPlanDTOList;
            }
            else
            {
                pageList.Data = null;
            }


            return(pageList);
        }
Exemplo n.º 10
0
        //get plan list with search criteria
        public static List <PlanDTO> GetPlanList(PagingInfo pagingInfo)
        {
            List <PlanDTO> PlanDTO = new List <PlanDTO>();

            //List<PartnerDTO> PartnerDTO = new List<PartnerDTO>();

            try
            {
                UnitOfWork uow  = new UnitOfWork();
                int        skip = (pagingInfo.Page - 1) * pagingInfo.ItemsPerPage;
                int        take = pagingInfo.ItemsPerPage;

                IQueryable <Plan> Plan = uow.PlanRepo.GetAll().AsQueryable();// .Where(e => e.PartnerId == PartnerId && e.IsActive == IsActive).ToList().AsQueryable();//.OrderBy(e => e.Company);
                Plan = PagingService.Sorting <Plan>(Plan, pagingInfo.SortBy, pagingInfo.Reverse);
                Plan = Plan.Skip(skip).Take(take);

                List <PlanDTO> PlanDTOList = new List <PlanDTO>();

                if (Plan != null)
                {
                    foreach (var item in Plan)
                    {
                        PlanDTOList.Add(Transform.PlanToDTO(item));
                    }
                }

                if (PlanDTOList != null)
                {
                    if (pagingInfo.Search != "" && pagingInfo.Search != null)
                    {
                        bool IsDate = CommonService.IsDate(pagingInfo.Search);
                        if (IsDate != true)
                        {
                            IQueryable <Plan> Plansearch = uow.PlanRepo.GetAll().Where(e => (e.Title != null ? (e.Title.ToLower().Contains(pagingInfo.Search.ToLower())) : false) || e.Price.ToString().ToLower().Contains(pagingInfo.Search.ToLower()) || (e.Min.ToString() != null ? (e.Min.ToString().Contains(pagingInfo.Search.ToString())) : false) || e.Max.ToString().Contains(pagingInfo.Search) || (e.Tax.ToString() != null ? (e.Tax.ToString().ToLower().Contains(pagingInfo.Search.ToLower())) : false)).AsQueryable(); //|| e.IsEcoupon.ToString().Contains(pagingInfo.Search) //.OrderBy(e => e.Company);
                            Plansearch = PagingService.Sorting <Plan>(Plansearch, pagingInfo.SortBy, pagingInfo.Reverse);
                            Plansearch = Plansearch.Skip(skip).Take(take);

                            if (Plansearch != null)
                            {
                                foreach (var item in Plansearch)
                                {
                                    PlanDTO.Add(Transform.PlanToDTO(item));
                                }
                            }
                            return(PlanDTO.Skip(skip).Take(take).ToList());
                        }
                        else
                        {
                            ////date wise search
                            //DateTime date = Convert.ToDateTime(pagingInfo.Search);
                        }
                    }
                    else
                    {
                        foreach (var item in PlanDTOList)
                        {
                            PlanDTO.Add(item);
                        }
                        return(PlanDTO.Skip(skip).Take(take).ToList());
                    }
                }

                return(PlanDTOList);
            }
            catch (Exception)
            {
                throw;
            }
        }