Exemplo n.º 1
0
        public List <AuthorDto> FindUsers(FindUsersDto userInfo)
        {
            List <User>      users     = userManager.FindUsers(userInfo);
            List <AuthorDto> usersDtos = mapper.FromUsersToAuthorsDtos(users);

            return(usersDtos);
        }
Exemplo n.º 2
0
        public List <User> FindUsers(FindUsersDto userInfo)
        {
            List <User> foundedUsers = dbContext.Users.ToList();

            if (userInfo.FirstName != null)
            {
                foundedUsers = foundedUsers.Where(u => u.FirstName == "Ivan").ToList();
            }

            if (userInfo.SecondName != null)
            {
                foundedUsers = foundedUsers.Where(u => u.SecondName == userInfo.SecondName).ToList();
            }

            if (userInfo.MiddleName != null)
            {
                foundedUsers = foundedUsers.Where(u => u.MiddleName == userInfo.MiddleName).ToList();
            }

            /*
             * DateTime now = DateTime.Now;
             * foundedUsers = foundedUsers.Where(u =>
             *  CalculateAge(u.BirthDate, now) <= userInfo.MaxAge && CalculateAge(u.BirthDate, now) >= userInfo.MinAge);*/
            return(foundedUsers);
        }
Exemplo n.º 3
0
        public ActionResult StartFindUsers(FindUsersDto userInfo)
        {
            if (ModelState.IsValid)
            {
                List <UserInfoDto> users        = userService.FindUsers(userInfo);
                FoundedUsersDto    foundedUsers = new FoundedUsersDto(userInfo, users);
                return(PartialView("FoundedUsersWall", foundedUsers));
            }

            return(RedirectToAction("FindUsers"));
        }
Exemplo n.º 4
0
        public ActionResult StartFindUsersFromPartial(string firstName, string secondName, string middleName, int minAge,
                                                      int maxAge)
        {
            FindUsersDto userInfo = new FindUsersDto()
            {
                FirstName  = firstName,
                SecondName = secondName,
                MiddleName = middleName,
                MinAge     = minAge,
                MaxAge     = maxAge
            };
            List <UserInfoDto> users        = userService.FindUsers(userInfo);
            FoundedUsersDto    foundedUsers = new FoundedUsersDto(userInfo, users);

            return(PartialView("FoundedUsersWall", foundedUsers));
        }
Exemplo n.º 5
0
        public List <User> FindUsers(FindUsersDto userInfo)
        {
            try
            {
                List <User> foundedUsers = dbContext.Users.ToList();
                if (userInfo.FirstName != null)
                {
                    foundedUsers = foundedUsers.Where(u => u.FirstName == userInfo.FirstName).ToList();
                }

                if (userInfo.SecondName != null)
                {
                    foundedUsers = foundedUsers.Where(u => u.SecondName == userInfo.SecondName).ToList();
                }

                if (userInfo.MiddleName != null)
                {
                    foundedUsers = foundedUsers.Where(u => u.MiddleName == userInfo.MiddleName).ToList();
                }

                if (userInfo.MinAge == null)
                {
                    userInfo.MinAge = 0;
                }

                if (userInfo.MaxAge == null)
                {
                    userInfo.MaxAge = 120;
                }

                DateTime now = DateTime.Now;
                foundedUsers = foundedUsers.Where(u => FindCorrectAge(userInfo.MinAge, userInfo.MaxAge, u.BirthDate))
                               .ToList();
                return(foundedUsers);
            }
            catch
            {
                throw;
            }
        }
Exemplo n.º 6
0
 public ActionResult AllDone(FindUsersDto test)
 {
     return(View(test));
 }
Exemplo n.º 7
0
        public ActionResult StartFindUsers(FindUsersDto userInfo)
        {
            List <AuthorDto> users = userService.FindUsers(userInfo);

            return(RedirectToAction("ShowFoundedUsers", "Page", new { foundedUsers = users }));
        }