Exemplo n.º 1
0
        public async Task <IActionResult> Get(ActionQueryArgs <ClientModel> args)
        {
            try
            {
                if (!string.IsNullOrEmpty(args.CondictionString))
                {
                    args.Condiction = JETech.DevExtremeCore.Converter.FilterToExpresion <ClientModel>(args.CondictionString);
                }
                var resultCli = _clientService.GetClients(args);

                var result = new ActionPaginationResult <List <ClientModel> >
                {
                    Data       = await resultCli.Data.AsNoTracking().ToListAsync(),
                    GroupCount = resultCli.GroupCount,
                    TotalCount = resultCli.TotalCount
                };

                return(Ok(result));
            }
            catch (Exception ex)
            {
                ModelState.AddModelError(String.Empty, JETechException.Parse(ex).AppMessage);
                throw;
            }
        }
Exemplo n.º 2
0
 public ActionPaginationResult <IQueryable <ClientModel> > GetClients(ActionQueryArgs <ClientModel> args)
 {
     try
     {
         return(_client.Get(args));
     }
     catch (Exception)
     {
         throw;
     }
 }
Exemplo n.º 3
0
        public ActionPaginationResult <IQueryable <t> > GetPaginationResult <t>(ActionQueryArgs <t> queryArgs, IQueryable <t> data)
        {
            IQueryable <t> newData    = null;
            int            totalCount = 0;

            try
            {
                if (queryArgs.PageArgs != null)
                {
                    int skip = 0;
                    int take = 0;

                    if (data != null)
                    {
                        totalCount = data.Count();

                        if (queryArgs.PageArgs.Size.HasValue)
                        {
                            take = (int)queryArgs.PageArgs.Size;
                        }

                        if (queryArgs.PageArgs.Skip.HasValue)
                        {
                            skip = (int)queryArgs.PageArgs.Skip;
                        }
                        else if (queryArgs.PageArgs.Num.HasValue)
                        {
                            skip = (int)(take * queryArgs.PageArgs.Num);
                        }
                        newData = data.Skip(skip).Take(take);
                    }
                }
                else
                {
                    newData = data;
                }
                return(new ActionPaginationResult <IQueryable <t> > {
                    Data = newData, TotalCount = totalCount
                });
            }
            catch (Exception ex)
            {
                throw;
            }
        }
Exemplo n.º 4
0
        public ActionPaginationResult <IQueryable <ClientModel> > Get(ActionQueryArgs <ClientModel> args)
        {
            try
            {
                var result = _sicDb.Clients
                             .Include(p => p.Person.Status)
                             .Select(c => new ClientModel {
                    Address        = c.Person.Address,
                    CellPhone      = c.Person.CellPhone,
                    City           = c.Person.City.Name,
                    Contry         = c.Person.Contry.Name,
                    Email          = c.Person.Email,
                    Fax            = c.Person.Fax,
                    FirstName      = c.Person.FirstName,
                    FullName       = c.Person.FullName,
                    HomePhone      = c.Person.HomePhone,
                    Id             = c.Id,
                    IdentityId     = c.Person.IdentityId,
                    LastName       = c.Person.LastName,
                    StatusId       = c.Person.Status.Id,
                    StatusName     = c.Person.Status.Name,
                    TypeIdentityId = c.Person.TypeIdentityId,
                    ZipCode        = c.Person.ZipCode
                });

                if (args.Condiction != null)
                {
                    result = result.Where(args.Condiction);
                }

                return(_actionHelper.GetPaginationResult <ClientModel>(args, result));
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }