Example #1
0
        private async void searchBtn_Click(object sender, EventArgs e)
        {
            Model.Requests.UserSearchRequest search = new Model.Requests.UserSearchRequest()
            {
                FirstName = FNSrch.Text,
                LastName  = LNSrch.Text,
                Userneme  = UNSrch.Text
            };
            var users = await _aspiService.Get <List <Model.User> >(search);

            var list = new List <Model.dgvLists.UserItem>();

            foreach (var user in users)
            {
                var Object = new Model.dgvLists.UserItem()
                {
                    Address     = user.Address,
                    BirthDate   = user.BirthDate.Date,
                    FirstName   = user.FirstName,
                    LastName    = user.LastName,
                    Mail        = user.Mail,
                    PhoneNumber = user.PhoneNumber,
                    UserId      = user.UserId,
                    Username    = user.Account.Username
                };
                list.Add(Object);
            }
            list.Sort((a, b) => a.FirstName.CompareTo(b.FirstName));
            dgvUsers.DataSource = list;
        }
Example #2
0
        public List <Model.User> Get(Model.Requests.UserSearchRequest request)
        {
            var query = _context.Users.Include(u => u.Account).AsQueryable();

            if (!string.IsNullOrWhiteSpace(request.FirstName))
            {
                query = query.Where(m => m.FirstName.ToLower().StartsWith(request.FirstName.ToLower()));
            }
            if (!string.IsNullOrWhiteSpace(request.LastName))
            {
                query = query.Where(m => m.LastName.ToLower().StartsWith(request.LastName.ToLower()));
            }
            if (!string.IsNullOrWhiteSpace(request.Userneme))
            {
                query = query.Where(m => m.Account.Username.ToLower().StartsWith(request.Userneme.ToLower()));
            }

            return(_mapper.Map <List <Model.User> >(query.ToList()));
        }
 public ActionResult <List <Model.User> > Get([FromQuery] Model.Requests.UserSearchRequest request)
 {
     return(_service.Get(request));
 }