Exemplo n.º 1
0
        public JArray Search([FromBody] ApplicationUserSearch data)
        {
            Dictionary <string, object> commandParams = new Dictionary <string, object>();

            commandParams.Add("@p_SortColumn", data.SortColumn);
            commandParams.Add("@p_SortOrder", data.SortOrder);
            commandParams.Add("@p_PageSize", data.PageSize);
            commandParams.Add("@p_PageStart", data.PageStart);

            if (data.ApplicationRoleID.HasValue)
            {
                commandParams.Add("@p_ApplicationRoleID", data.ApplicationRoleID);
            }

            if (data.ApplicationUserID.HasValue)
            {
                commandParams.Add("@p_ApplicationUserID", data.ApplicationUserID);
            }

            commandParams.Add("@p_LoginName", data.LoginName);

            DynamicList lst = DynamicList.GetData("[dbo].[spCFM_ApplicationUser_SelectForGrid]", commandParams);

            if (lst.Count > 0)
            {
                var data1 = (JArray)lst[0].GetValue("Data");
                return(data1);
            }

            return(null);
        }
Exemplo n.º 2
0
        private async void btnPrikazi_Click(object sender, EventArgs e)
        {
            //pozivamo api
            //var result = await "https://localhost:44377/api/ApplicationUser".GetJsonAsync<List<Models.ApplicationUser.ApplicationUser>>();
            var search = new ApplicationUserSearch()
            {
                Ime = txtPretraga.Text
            };

            var result = await _apiService.Get <List <Models.ApplicationUser.ApplicationUser> >(search);

            // dgvKorisnici.AutoGenerateColumns = false;//da ne generise samo sve nego samo sto je tamo stavljeno u grid
            dgvKorisnici.DataSource = result;
        }
Exemplo n.º 3
0
        List <Models.ApplicationUser.ApplicationUser> IApplicationUser.Get(ApplicationUserSearch search)
        {
            //var list = _ctx.ApplicationUser
            //    .Include(a => a.Opcina)
            //    .ToList();
            var querry = _ctx.ApplicationUser.Include(a => a.Opcina).AsQueryable();

            if (!string.IsNullOrWhiteSpace(search?.Ime))
            {
                querry = querry.Where(x => x.Ime.StartsWith(search.Ime));
            }
            if (!string.IsNullOrWhiteSpace(search?.Prezime))
            {
                querry = querry.Where(x => x.Prezime.StartsWith(search.Prezime));
            }
            var list = querry.ToList();

            return(_mapper.Map <List <Models.ApplicationUser.ApplicationUser> >(list));
        }
        public IEnumerable <GetApplicationUserDto> Execute(ApplicationUserSearch request)
        {
            var query = context.ApplicaitonUsers.AsQueryable();

            if (request.FirstNameKeyword != null)
            {
                query = query
                        .Where(x =>
                               x.FirstName.ToLower().Contains(request.FirstNameKeyword.ToLower()));
            }

            if (request.LastNameKeyword != null)
            {
                query = query
                        .Where(x =>
                               x.LastName.ToLower().Contains(request.LastNameKeyword.ToLower()));
            }

            if (request.EmailKeyword != null)
            {
                query = query
                        .Where(x =>
                               x.Email.ToLower().Contains(request.EmailKeyword.ToLower()));
            }

            if (request.RoleId != null)
            {
                query = query.Where(x => x.RoleId == request.RoleId);
            }

            if (request.OnlyActive.HasValue)
            {
                if (request.OnlyActive == true)
                {
                    query = query.Where(x => x.DeletedAt == null);
                }
            }

            query = query.SkipItems(request.Page, request.ItemsPerPage);

            return(query.Select(x => _mapper.Map <ApplicationUser, GetApplicationUserDto>(x)).ToList());
        }
Exemplo n.º 5
0
        public override async Task <Tuple <List <Model.Response.ApplicationUser>, int> > GetByParametersAsync(ApplicationUserSearch search, string order, string nameOfColumnOrder, int start, int length)
        {
            var query = context.Users.AsQueryable();

            if (!string.IsNullOrWhiteSpace(search.Username))
            {
                query = query.Where(x => x.UserName.Contains(search.Username));
            }
            if (!string.IsNullOrWhiteSpace(search.Email))
            {
                query = query.Where(x => x.Email.Contains(search.Email));
            }
            if (search.Active != null)
            {
                query = query.Where(x => x.Active == search.Active);
            }

            if (nameOfColumnOrder == nameof(Database.ApplicationUser.UserName))
            {
                query = query.OrderByAscDesc(x => x.UserName, order);
            }
            else if (nameOfColumnOrder == nameof(Database.ApplicationUser.Email))
            {
                query = query.OrderByAscDesc(x => x.Email, order);
            }
            else if (nameOfColumnOrder == nameof(Database.ApplicationUser.PhoneNumber))
            {
                query = query.OrderByAscDesc(x => x.PhoneNumber, order);
            }

            return(new Tuple <List <Model.Response.ApplicationUser>, int>(mapper.Map <List <Model.Response.ApplicationUser> >(await query.Skip(start).Take(length).ToListAsync()), await query.CountAsync()));
        }
 public ActionResult <List <Models.ApplicationUser.ApplicationUser> > Get([FromQuery] ApplicationUserSearch search)
 {
     return(_service.Get(search));
 }
Exemplo n.º 7
0
        public IActionResult Get([FromQuery] ApplicationUserSearch search, [FromServices] IGetApplicationUsersQuery query)
        {
            IEnumerable <GetApplicationUserDto> applicationUsers = _useCaseExecutor.ExecuteQuery(query, search);

            return(Ok(applicationUsers));
        }