Exemplo n.º 1
0
        public int Count(UserSearchEntity UserSearchEntity)
        {
            if (UserSearchEntity == null)
            {
                UserSearchEntity = new UserSearchEntity();
            }
            IQueryable <User> Users = readContext.Users;

            Users = Apply(Users, UserSearchEntity);
            return(Users.Count());
        }
Exemplo n.º 2
0
        public List <User> List(UserSearchEntity UserSearchEntity)
        {
            IQueryable <User> Users = readContext.Users
                                      .AsNoTracking()
                                      .OrderBy(m => m.name);

            Users = Apply(Users, UserSearchEntity);
            Users = SkipAndTake(Users, UserSearchEntity);
            Users.OrderBy(m => m.name);
            return(Users.ToList());
        }
Exemplo n.º 3
0
 private IQueryable <User> Apply(IQueryable <User> Users, UserSearchEntity UserSearchEntity)
 {
     if (UserSearchEntity.id.HasValue)
     {
         Users = Users.Where(wh => wh.id == UserSearchEntity.id.Value);
     }
     if (!string.IsNullOrEmpty(UserSearchEntity.name))
     {
         Users = Users.Where(mc => mc.name.Contains(UserSearchEntity.name));
     }
     Users = Users.OrderBy(m => m.name);
     //if (!string.IsNullOrEmpty(VendorSearchEntity.name))
     //    Vendors = Vendors.Where(T => T.Code.ToLower().Contains(VendorSearchEntity.Code.ToLower()));
     //if (VendorSearchEntity.ParentId.HasValue)
     //    Vendors = Vendors.Where(T => T.ParentId.HasValue && T.ParentId.Value == VendorSearchEntity.ParentId.Value);
     return(Users);
 }
Exemplo n.º 4
0
        private string ExpectedResult()
        {
            using StreamReader r = new StreamReader("Data/userResult.json");
            string json = r.ReadToEnd();

            var expectedResponse = new List <UserSearchEntity>();
            var user             = JsonConvert.DeserializeObject <User>(json);
            var userEntity       = new UserSearchEntity()
            {
                User             = user,
                OrganizationName = "Geekfarm",
                TicketSubjects   = new List <string> {
                    "A Catastrophe in Maldives", "A Catastrophe in US Minor Outlying Islands", "A Drama in Indonesia", "A Nuisance in Chile", "A Catastrophe in Gibraltar", "A Catastrophe in Brazil", "A Nuisance in Bhutan", "A Drama in Canada", "A Nuisance in Uganda", "A Nuisance in United States", "A Catastrophe in Singapore", "A Drama in Kazakhstan", "A Problem in Malawi"
                }
            };

            expectedResponse.Add(userEntity);

            return(JsonConvert.SerializeObject(expectedResponse));
        }
Exemplo n.º 5
0
        public List <UserSearchEntity> GetUserDetails(string key, string value)
        {
            var userDetails  = new List <UserSearchEntity>();
            var titleCaseKey = TitleCaseString.ToTitleCase(key);

            using StreamReader r = new StreamReader(_userFilePath);
            string json     = r.ReadToEnd();
            var    allUsers = JsonConvert.DeserializeObject <List <User> >(json);

            foreach (var user in allUsers)
            {
                var mapUser = new UserSearchEntity();
                if (user.GetType().GetTypeInfo().GetDeclaredProperty(titleCaseKey) != null)
                {
                    if (user.GetType().GetProperty(titleCaseKey).GetValue(user)?.ToString() == value)
                    {
                        if (user?.Organization_Id != 0)
                        {
                            var orgDetails           = _getOrg.GetOrganizationDetails("Id", user.Organization_Id.ToString());
                            var ticketSubjectDetails = GetTicketsSubject(user.Organization_Id);
                            mapUser.OrganizationName = orgDetails?.FirstOrDefault(r => r.Id == user?.Organization_Id).Name;
                            mapUser.User             = user;
                            mapUser.TicketSubjects   = ticketSubjectDetails;
                        }
                        userDetails.Add(mapUser);
                    }
                }
                else
                {
                    Console.WriteLine("Please enter a valid search term");
                    _logger.LogInformation($"Invalid search term {key}");
                    userDetails = null;
                    break;
                }
            }
            return(userDetails);
        }
Exemplo n.º 6
0
 public List <UserEntity> Get(UserSearchEntity UserSearchEntity)
 {
     return(UserService.Get(UserSearchEntity));
 }
Exemplo n.º 7
0
 public long Count(UserSearchEntity UserSearchEntity)
 {
     return(UserService.Count(UserSearchEntity));
 }
Exemplo n.º 8
0
        public List <UserEntity> Get(UserSearchEntity UserSearchEntity)
        {
            List <User> Users = userRepository.List(UserSearchEntity);

            return(Users.Select(u => new UserEntity(u)).ToList());
        }
Exemplo n.º 9
0
 public int Count(UserSearchEntity UserSearchEntity)
 {
     return(userRepository.Count(UserSearchEntity));
 }