public PagedResult <AllSolicitationSubsidyDto> AgentPagination([FromQuery] FilterSolicitationSubsidyDto filters)
        {
            var       agentId    = GetIdUser();
            const int pageSize   = 10;
            var       resultFull = new List <AllSolicitationSubsidyDto>();
            var       result     = new object();
            int       totalRows  = 0;
            var       pageIndex  = filters.Page == 0 ? 1 : filters.Page;

            var results = _dataContext.GetSolicitationsByAgent(agentId, filters.FirstName,
                                                               filters.LastName, filters.Dni, "FIRSTNAME ASC", pageSize, pageIndex);

            return(new PagedResult <AllSolicitationSubsidyDto>
            {
                List = results.List.Select(_mapper.Map <AllSolicitationSubsidyDto>).OrderByDescending(x => x.CreateDate).ToList(),
                TotalRecords = results.TotalRecords
            });
        }
        public PagedResult <AllSolicitationSubsidyDto> SupervisorPaginationAsync(
            [FromQuery] FilterSolicitationSubsidyDto filters)
        {
            const int pageSize     = 10;
            var       resultFull   = new List <AllSolicitationSubsidyDto>();
            var       result       = new object();
            int       totalRows    = 0;
            var       supervisorId = GetIdUser();
            var       pageIndex    = filters.Page == 0 ? 1 : filters.Page;

            var results = _dataContext.GetAgentsSolicitationBySupervisor(supervisorId, filters.FirstName,
                                                                         filters.LastName, filters.Dni, "FIRSTNAME ASC", pageSize, pageIndex, filters.IsRefund);

            return(new PagedResult <AllSolicitationSubsidyDto>()
            {
                List = results.List.Select(_mapper.Map <AllSolicitationSubsidyDto>).ToList(),
                TotalRecords = results.TotalRecords
            });
        }
Пример #3
0
        public ServiceResult <List <AllSolicitationSubsidyDto> > Get_agents_solicitation_by_supervisor(
            Guid Supervisor, Guid AgentId, FilterSolicitationSubsidyDto filters)
        {
            using (var connection = new SqlConnection(ConnectionString))
            {
                connection.Open();
                var item      = new List <AllSolicitationSubsidyDto>();
                var pageIndex = filters.Page == 0 ? 1 : filters.Page;

                using (var command = new SqlCommand("exec get_agents_solicitation_by_supervisor " +
                                                    "@SupervisorId = '" + Supervisor + "' , " +
                                                    "@AgentId = '" + AgentId + "' , " +
                                                    "@PageSize = '" + 1 + "' ," +
                                                    "@PageIndex = '" + pageIndex + "' , " +
                                                    "@FirstName = '" + filters.FirstName + "' , " +
                                                    "@LastName = '" + filters.LastName + "' , " +
                                                    "@Dni = '" + filters.Dni + "' , " +
                                                    "@SortBy = 'FIRSTNAME ASC' ", connection))
                {
                    using (var dataReader = command.ExecuteReader())
                    {
                        while (dataReader.Read())
                        {
                            item.Add(
                                new AllSolicitationSubsidyDto()
                            {
                                Id         = dataReader.GetGuid(0),
                                FullName   = dataReader.GetString(1),
                                CreateDate = dataReader.GetDateTime(2),
                                Motive     = dataReader.GetString(3),
                                Localities = dataReader.GetString(4),
                                Total      = dataReader.GetDecimal(5),
                                State      = dataReader.GetString(6)
                            }
                                );
                        }
                    }
                }
                connection.Close();
                return(new ServiceResult <List <AllSolicitationSubsidyDto> >(item));
            }
        }
Пример #4
0
        public PagedResult <AllSolicitationSubsidyDto> AgentPagination([FromQuery] FilterSolicitationSubsidyDto filters)
        {
            var       agentId    = GetIdUser();
            const int pageSize   = 10;
            var       resultFull = new List <AllSolicitationSubsidyDto>();
            var       result     = new object();
            int       totalRows  = 0;
            var       pageIndex  = filters.Page == 0 ? 1 : filters.Page;

            var results = _dataContext.GetSolicitationsByAgent(agentId, filters.FirstName,
                                                               filters.LastName, filters.Dni, "FIRSTNAME ASC", pageSize, pageIndex);

            foreach (var s in results.List)
            {
                if (!s.IsRefund && s.FinalizeDate == null && s.State == "Aceptado")
                {
                    if (DateTime.Today.CompareTo(s.EndDate.Value) >= 0)
                    {
                        var solicitation = _dataContext.SolicitationSubsidies.FirstOrDefault(sol => sol.Id == s.Id);
                        SolicitationState solicitationState = new SolicitationState()
                        {
                            Id = new Guid(),
                            SolicitationSubsidy = solicitation,
                            ChangeDate          = DateTime.Now,
                            StateId             = State.Finished
                        };
                        _dataContext.SolicitationStates.Add(solicitationState);
                        solicitation.FinalizeDate = s.EndDate;
                        s.FinalizeDate            = s.EndDate;
                        _dataContext.SolicitationSubsidies.Update(solicitation);
                        _dataContext.SaveChanges();
                    }
                }
            }

            return(new PagedResult <AllSolicitationSubsidyDto>
            {
                List = results.List.Select(_mapper.Map <AllSolicitationSubsidyDto>).OrderByDescending(x => x.CreateDate).ToList(),
                TotalRecords = results.TotalRecords
            });
        }