Beispiel #1
0
        public GetGeneralResponse <IEnumerable <CreditServiceView> > GetCreditServices(int pageSize, int pageNumber, IList <Sort> sort, IList <FilterData> filter)
        {
            GetGeneralResponse <IEnumerable <CreditServiceView> > response = new GetGeneralResponse <IEnumerable <CreditServiceView> >();

            try
            {
                int index = (pageNumber - 1) * pageSize;
                int count = pageSize;

                string query = FilterUtilityService.GenerateFilterHQLQuery(filter, "CreditService", sort);

                Response <CreditService> creditService = new Response <CreditService>();
                creditService = _creditServiceRepository.FindAll(query, index, count);

                response.data       = creditService.data.ConvertToCreditServiceViews();
                response.totalCount = creditService.totalCount;
            }
            catch (Exception ex)
            {
                response.ErrorMessages.Add(ex.Message);
                if (ex.InnerException != null)
                {
                    response.ErrorMessages.Add(ex.InnerException.Message);
                }
            }

            return(response);
        }
Beispiel #2
0
        public GetGeneralResponse <IEnumerable <FiscalView> > GetAllFiscals(int pageSize, int pageNumber, IList <Sort> sort, IList <FilterData> filter)
        {
            GetGeneralResponse <IEnumerable <FiscalView> > response = new GetGeneralResponse <IEnumerable <FiscalView> >();

            try
            {
                int index = (pageNumber - 1) * pageSize;
                int count = pageSize;

                //foreach (var item in sort)
                //{
                //    if (item.SortColumn == "Balance")
                //        item.SortColumn = "Customer.Balance";
                //}

                string            query   = FilterUtilityService.GenerateFilterHQLQuery(filter, "Fiscal", sort);
                Response <Fiscal> fiscals = _fiscalRepository.FindAll(query, index, count);

                response.data       = fiscals.data.ConvertToFiscalViews();
                response.totalCount = fiscals.totalCount;
            }
            catch (Exception ex)
            {
                response.ErrorMessages.Add(ex.Message);
                if (ex.InnerException != null)
                {
                    response.ErrorMessages.Add(ex.InnerException.Message);
                }
            }


            return(response);
        }
Beispiel #3
0
        public GetGeneralResponse <IEnumerable <LocalPhoneView> > GetLocalPhones(int pageSize, int pageNumber,
                                                                                 List <FilterData> filter, IList <Sort> sort)
        {
            GetGeneralResponse <IEnumerable <LocalPhoneView> > response =
                new GetGeneralResponse <IEnumerable <LocalPhoneView> >();


            int index = (pageNumber - 1) * pageSize;
            int count = pageSize;
            Response <LocalPhone> localPhones = new Response <LocalPhone>();
            string query = FilterUtilityService.GenerateFilterHQLQuery(filter, "LocalPhone", sort);

            if (count > 0)
            {
                localPhones = _localPhoneRepository.FindAll(query, index, count);
            }
            else
            {
                localPhones = _localPhoneRepository.FindAll(query);
            }
            response.data       = localPhones.data.ConvertToLocalPhoneViews();
            response.totalCount = localPhones.totalCount;

            return(response);
        }
Beispiel #4
0
        public GetGeneralResponse <IEnumerable <GetcampaignAgents> > GetSuctionModeCostReport3(IList <FilterData> filter, IList <Sort> sort)
        {
            GetGeneralResponse <IEnumerable <GetcampaignAgents> > response = new GetGeneralResponse <IEnumerable <GetcampaignAgents> >();

            string query = FilterUtilityService.GenerateFilterHQLQuery(filter, "CampaignPayment", sort);

            Response <CampaignPayment> campaignPayment = _campaignPaymentRepository.FindBy(query);

            IList <GetcampaignAgents> list = new List <GetcampaignAgents>();

            foreach (var item in campaignPayment.data)
            {
                list.Add(new GetcampaignAgents()
                {
                    PaymentDate           = item.PaymentDate,
                    SuctionModeDetailID   = item.SuctionModeDetail.ID,
                    SuctionModeID         = item.SuctionModeDetail.SuctionMode.ID,
                    SuctionMoedName       = item.SuctionModeDetail.SuctionModeDetailName,
                    SuctionModeDetailName = item.SuctionModeDetail.SuctionMode.SuctionModeName,
                    Amount = item.Amount
                });
            }
            response.data       = list;
            response.totalCount = list.Count();

            return(response);
        }
Beispiel #5
0
        public GetGeneralResponse <IEnumerable <NotificationView> > GetNotifications(IList <FilterData> filter, IList <Sort> sort, int pageSize, int pageNumber)
        {
            GetGeneralResponse <IEnumerable <NotificationView> > response = new GetGeneralResponse <IEnumerable <NotificationView> >();

            try
            {
                int index = (pageNumber - 1) * pageSize;
                int count = pageSize;

                string query = FilterUtilityService.GenerateFilterHQLQuery(filter, "Notification", sort);

                Response <Notification> notifications = _notificationRepository.FindAll(query);

                response.data       = notifications.data.ConvertToNotificationViews();
                response.totalCount = notifications.totalCount;
            }
            catch (Exception ex)
            {
                response.ErrorMessages.Add(ex.Message);
                if (ex.InnerException != null)
                {
                    response.ErrorMessages.Add(ex.InnerException.Message);
                }
            }

            return(response);
        }
Beispiel #6
0
        public GetGeneralResponse <IEnumerable <GetSuctionModeCost1View> > GetSuctionModeCostReport1(IList <FilterData> filter, IList <Sort> sort)
        {
            GetGeneralResponse <IEnumerable <GetSuctionModeCost1View> > response = new GetGeneralResponse <IEnumerable <GetSuctionModeCost1View> >();

            string query = FilterUtilityService.GenerateFilterHQLQuery(filter, "CampaignPayment", sort);

            Response <CampaignPayment>      campaignPayment = _campaignPaymentRepository.FindBy(query);
            IList <GetSuctionModeCost1View> list            = new List <GetSuctionModeCost1View>();

            foreach (var item in campaignPayment.data)
            {
                GetSuctionModeCost1View getSuctionModeCost1View = new GetSuctionModeCost1View();
                getSuctionModeCost1View.CampaignAgentName     = item.CampaignAgent.CampaignAgentName;
                getSuctionModeCost1View.Amount                = item.Amount;
                getSuctionModeCost1View.SuctionModeDetailName = item.SuctionModeDetail.SuctionModeDetailName;
                getSuctionModeCost1View.SuctionModeName       = item.SuctionModeDetail.SuctionMode.SuctionModeName;
                getSuctionModeCost1View.PaymentDate           = item.PaymentDate;

                list.Add(getSuctionModeCost1View);
            }

            response.data       = list;
            response.totalCount = list.Count();

            return(response);
        }
Beispiel #7
0
        public GetGeneralResponse <IEnumerable <GetSuctionModeCost2View> > GetSuctionModeCostReport2(IList <FilterData> filter, IList <Sort> sort)
        {
            GetGeneralResponse <IEnumerable <GetSuctionModeCost2View> > response = new GetGeneralResponse <IEnumerable <GetSuctionModeCost2View> >();

            string query = FilterUtilityService.GenerateFilterHQLQuery(filter, "CampaignPayment", sort);

            Response <CampaignPayment> campaignPayment = _campaignPaymentRepository.FindBy(query);
            var result = campaignPayment.data.GroupBy(l => l.CampaignAgent.ID)
                         .Select(lg =>
                                 new
            {
                ID            = lg.Key,
                Sum           = lg.Sum(x => x.Amount),
                CampaignAgent = lg.FirstOrDefault().CampaignAgent.CampaignAgentName,
            });
            IList <GetSuctionModeCost2View> list = new List <GetSuctionModeCost2View>();

            foreach (var item in result)
            {
                GetSuctionModeCost2View getSuctionModeCost1View = new GetSuctionModeCost2View();
                getSuctionModeCost1View.ID = item.ID;
                getSuctionModeCost1View.CampaignAgentName = item.CampaignAgent;
                getSuctionModeCost1View.Amount            = item.Sum;

                list.Add(getSuctionModeCost1View);
            }

            response.data       = list;
            response.totalCount = list.Count();

            return(response);
        }
        public GetGeneralResponse <IEnumerable <LocalPhoneStoreView> > GetLocalPhoneStores(int pageSize, int pageNumber,
                                                                                           IList <FilterData> filter, IList <Sort> sort)
        {
            var response = new GetGeneralResponse <IEnumerable <LocalPhoneStoreView> >();

            try
            {
                int    index = (pageNumber - 1) * pageSize;
                int    count = pageSize;
                string query = FilterUtilityService.GenerateFilterHQLQuery(filter, "LocalPhoneStore", sort);

                Response <LocalPhoneStore> localPhoneStores = _localPhoneStoreRepository.FindAll(query, index, count);

                response.data       = localPhoneStores.data.ConvertToLocalPhoneStoreViews();
                response.totalCount = localPhoneStores.totalCount;
            }
            catch (Exception ex)
            {
                response.ErrorMessages.Add(ex.Message);
                if (ex.InnerException != null)
                {
                    response.ErrorMessages.Add(ex.InnerException.Message);
                }
            }

            return(response);
        }
Beispiel #9
0
        public GetGeneralResponse <IEnumerable <NegotiationView> > GetChildNegotiations(Guid EmployeeID, int pageSize,
                                                                                        int pageNumber, IList <FilterData> filter, IList <Sort> sort)
        {
            GetGeneralResponse <IEnumerable <NegotiationView> > response = new GetGeneralResponse <IEnumerable <NegotiationView> >();

            try
            {
                Employee     employee = _employeeRepository.FindBy(EmployeeID);
                IList <Guid> ChildIds = new List <Guid>();
                var          temp     = employee.GetAllChild();
                foreach (var item in temp)
                {
                    ChildIds.Add(item.ID);
                }
                IList <FilterData> Filters = new List <FilterData>();
                int index = (pageNumber - 1) * pageSize;
                int count = pageSize;
                if (filter != null)
                {
                    foreach (var item in filter)
                    {
                        Filters.Add(item);
                    }
                }
                IList <string> Ids = new List <string>();
                foreach (var item in ChildIds)
                {
                    Ids.Add(item.ToString());
                }
                Filters.Add(new FilterData()
                {
                    data = new data()
                    {
                        comparison = "eq",
                        type       = "list",
                        value      = Ids.ToArray()
                    },
                    field = "ReferedEmployee.ID"
                });

                string query = FilterUtilityService.GenerateFilterHQLQuery(Filters, "Negotiation", sort);
                Response <Negotiation> negotiations = _negotiationRepository.FindAll(query, index, count);

                response.data       = negotiations.data.ConvertToNegotiationViews();
                response.totalCount = negotiations.totalCount;
            }
            catch (Exception ex)
            {
                response.ErrorMessages.Add(ex.Message);
                if (ex.InnerException != null)
                {
                    response.ErrorMessages.Add(ex.InnerException.Message);
                }
            }

            return(response);
        }
Beispiel #10
0
        public GetGeneralResponse <IEnumerable <FiscalView> > GetFiscals(Guid customerID, int pageSize, int pageNumber, IList <Sort> sort, IList <FilterData> filter)
        {
            GetGeneralResponse <IEnumerable <FiscalView> > response = new GetGeneralResponse <IEnumerable <FiscalView> >();

            try
            {
                int index = (pageNumber - 1) * pageSize;
                int count = pageSize;


                IList <FilterData> _filter = new List <FilterData>();

                _filter.Add(new FilterData()
                {
                    data = new data()
                    {
                        comparison = "eq",
                        type       = "string",
                        value      = new[] { customerID.ToString() }
                    },
                    field = "Customer.ID"
                });

                if (filter != null)
                {
                    foreach (var item in filter)
                    {
                        _filter.Add(item);
                    }
                }

                foreach (var item in sort)
                {
                    if (item.SortColumn == "Balance")
                    {
                        item.SortColumn = "Customer.Balance";
                    }
                }

                string newquery = FilterUtilityService.GenerateFilterHQLQuery(_filter, "Fiscal", sort);

                Response <Fiscal> fiscals = _fiscalRepository.FindAll(newquery, index, count);

                response.data       = fiscals.data.ConvertToFiscalViews();
                response.totalCount = fiscals.totalCount;
            }
            catch (Exception ex)
            {
                response.ErrorMessages.Add(ex.Message);
            }


            return(response);
        }
Beispiel #11
0
        public GetGeneralResponse <IEnumerable <ProductLogView> > GetProductLogsByFilter(IList <FilterData> filters)
        {
            GetGeneralResponse <IEnumerable <ProductLogView> > response = new GetGeneralResponse <IEnumerable <ProductLogView> >();

            string query = FilterUtilityService.GenerateFilterHQLQuery(filters, "ProductLog", null);
            Response <ProductLog> productLogViews = _productLogRepository.FindBy(query);

            response.data       = productLogViews.data.ConvertToProductLogViews();
            response.totalCount = productLogViews.totalCount;

            return(response);
        }
Beispiel #12
0
        public GetGeneralResponse <IEnumerable <NotificationView> > NotificationReadByEmployee(Guid ReferedEmployeeID, int pageSize, int pageNumber, IList <FilterData> filter, IList <Sort> sort)
        {
            GetGeneralResponse <IEnumerable <NotificationView> > response = new GetGeneralResponse <IEnumerable <NotificationView> >();

            IList <FilterData> Filter = new List <FilterData>();

            if (filter != null)
            {
                foreach (var item in filter)
                {
                    Filter.Add(item);
                }
            }

            Filter.Add(new FilterData()
            {
                data = new data()
                {
                    comparison = "eq",
                    type       = "string",
                    value      = new[] { ReferedEmployeeID.ToString() }
                },
                field = "ReferedEmployee.ID"
            });

            try
            {
                int index = (pageNumber - 1) * pageSize;
                int count = pageSize;

                string query = FilterUtilityService.GenerateFilterHQLQuery(Filter, "Notification", sort);

                Response <Notification> notifications = _notificationRepository.FindAll(query, index, count);

                response.data       = notifications.data.ConvertToNotificationViews();
                response.totalCount = notifications.totalCount;
            }

            catch (Exception ex)
            {
                response.ErrorMessages.Add(ex.Message);
                if (ex.InnerException != null)
                {
                    response.ErrorMessages.Add(ex.InnerException.Message);
                }
            }

            return(response);
        }
Beispiel #13
0
        public GetGeneralResponse <IEnumerable <CallLogView> > GetOwnCallLog(int pageSize, int pageNumber,
                                                                             IList <FilterData> filter, IList <Sort> sort, Guid EmployeeID)
        {
            var response = new GetGeneralResponse <IEnumerable <CallLogView> >();

            try
            {
                IList <FilterData> Filters = new List <FilterData>();
                if (filter != null)
                {
                    foreach (var item in filter)
                    {
                        Filters.Add(item);
                    }
                }
                Filters.Add(new FilterData()
                {
                    data = new data()
                    {
                        comparison = "eq",
                        type       = "list",
                        value      = new [] { EmployeeID.ToString() }
                    },
                    field = "CreateEmployee"
                });

                int index = (pageNumber - 1) * pageSize;
                int count = pageSize;

                string             query    = FilterUtilityService.GenerateFilterHQLQuery(Filters, "CallLog", sort);
                Response <CallLog> callLogs = _callLogRepository.FindAll(query, index, count);

                response.data       = callLogs.data.ConvertToCallLogViews();
                response.totalCount = callLogs.totalCount;
            }
            catch (Exception ex)
            {
                response.ErrorMessages.Add(ex.Message);
                if (ex.InnerException != null)
                {
                    response.ErrorMessages.Add(ex.InnerException.Message);
                }
            }

            return(response);
        }
Beispiel #14
0
        public GetGeneralResponse <IEnumerable <EmployeeView> > GetEmployees(Guid?groupID, int pageSize, int pageNumber, List <FilterData> filter, List <Sort> sort)
        {
            GetGeneralResponse <IEnumerable <EmployeeView> > response = new GetGeneralResponse <IEnumerable <EmployeeView> >();

            try
            {
                int index = (pageNumber - 1) * pageSize;
                int count = pageSize;

                Response <Employee> employees = new Response <Employee>();

                if (groupID != null)
                {
                    Query     query    = new Query();
                    Criterion criteria = new Criterion("Group.ID", groupID, CriteriaOperator.Equal);
                    query.Add(criteria);

                    employees = _employeeRepository.FindBy(query, index, count);
                }
                else
                {
                    string query = FilterUtilityService.GenerateFilterHQLQuery(filter, "Employee", sort);
                    if (count == -1)
                    {
                        employees = _employeeRepository.FindAll(query);
                    }
                    else
                    {
                        employees = _employeeRepository.FindAll(query, index, count);
                    }
                }
                foreach (var item in employees.data)
                {
                    item.Permissions = null;
                }
                response.data = employees.data.ConvertToEmployeeViews();

                response.totalCount = employees.totalCount;
            }
            catch (Exception ex)
            {
                response.ErrorMessages.Add(ex.Message);
            }
            return(response);
        }
Beispiel #15
0
        public GetGeneralResponse <IEnumerable <CourierView> > GetAllCouriers(int pageSize, int pageNumber,
                                                                              IList <FilterData> filter, IList <Sort> sort)
        {
            GetGeneralResponse <IEnumerable <CourierView> > response = new GetGeneralResponse <IEnumerable <CourierView> >();

            try
            {
                int index = (pageNumber - 1) * pageSize;
                int count = pageSize;

                string             query    = FilterUtilityService.GenerateFilterHQLQuery(filter, "Courier", sort);
                Response <Courier> couriers = _courierRepository.FindAll(query, index, count);


                foreach (var item in couriers.data)
                {
                    long Bonus = 0;
                    if (item.Sale.UncreditSaleDetails.Any())
                    {
                        Bonus += item.Sale.UncreditSaleDetails.Sum(x => x.Bonus);
                    }
                    if (item.Sale.CreditSaleDetails.Any())
                    {
                        Bonus += item.Sale.CreditSaleDetails.Sum(x => x.Bonus);
                    }
                    if (item.Sale.ProductSaleDetails.Any())
                    {
                        Bonus += item.Sale.ProductSaleDetails.Sum(x => x.Bonus);
                    }
                    item.Bonus = Bonus;
                }
                response.data       = couriers.data.ConvertToCourierViews();
                response.totalCount = couriers.totalCount;
            }
            catch (Exception ex)
            {
                response.ErrorMessages.Add(ex.Message);
                if (ex.InnerException != null)
                {
                    response.ErrorMessages.Add(ex.InnerException.Message);
                }
            }

            return(response);
        }
Beispiel #16
0
        public GetGeneralResponse <IEnumerable <ProductSaleDetailView> > GetProductSaleDetails(IList <FilterData> filters)
        {
            GetGeneralResponse <IEnumerable <ProductSaleDetailView> > response = new GetGeneralResponse <IEnumerable <ProductSaleDetailView> >();

            try
            {
                string query = FilterUtilityService.GenerateFilterHQLQuery(filters, "ProductSaleDetail", null);
                Response <ProductSaleDetail> productSaleDetails = _productSaleDetailRepository.FindBy(query);

                response.data       = productSaleDetails.data.ConvertToProductSaleDetailViews();
                response.totalCount = productSaleDetails.totalCount;
            }
            catch (Exception ex)
            {
                response.ErrorMessages.Add(ex.Message);
            }

            return(response);
        }
Beispiel #17
0
        public GetGeneralResponse <IEnumerable <CenterView> > GetCenters(int pageSize, int pageNumber, string CenterName, IList <Sort> sort, IList <FilterData> filter)
        {
            GetGeneralResponse <IEnumerable <CenterView> > response = new GetGeneralResponse <IEnumerable <CenterView> >();

            try
            {
                int index = (pageNumber - 1) * pageSize;
                int count = pageSize;
                Response <Center> centersResponse = new Response <Center>();
                if (CenterName != null)
                {
                    Infrastructure.Querying.Query query = new Infrastructure.Querying.Query();
                    Criterion CriteriaCentrName         = new Criterion("CenterName", CenterName, CriteriaOperator.Contains);
                    query.Add(CriteriaCentrName);
                    centersResponse = _centerRepository.FindBy(query, -1, -1, null);
                }
                else
                {
                    if (index < 0 || count < 0)
                    {
                        string query = FilterUtilityService.GenerateFilterHQLQuery(filter, "Center", sort);
                        centersResponse = _centerRepository.FindAll(query);
                    }
                    else
                    {
                        string query = FilterUtilityService.GenerateFilterHQLQuery(filter, "Center", sort);
                        centersResponse = _centerRepository.FindAll(query, index, count);
                    }
                }
                response.data       = centersResponse.data.ConvertToCenterViews();
                response.totalCount = centersResponse.totalCount;
            }
            catch (Exception ex)
            {
                response.ErrorMessages.Add(ex.Message);
            }

            return(response);
        }
Beispiel #18
0
        public GetGeneralResponse <IEnumerable <AgencyView> > GetAgencies(bool?Discontinued, int pageSize, int pageNumber, IList <Sort> sort, IList <FilterData> filter)
        {
            GetGeneralResponse <IEnumerable <AgencyView> > response = new GetGeneralResponse <IEnumerable <AgencyView> >();

            try
            {
                int index = (pageNumber - 1) * pageSize;
                int count = pageSize;
                Response <Agency> agencies = new Response <Agency>();
                //IList<Sort> sortOrders = new List<Sort>();
                //sortOrders.Add(new Sort("SortOrder"));
                if (filter != null)
                {
                    string query = FilterUtilityService.GenerateFilterHQLQuery(filter, "Agency", sort);
                    agencies = _agencyRepository.FindAll(query, index, count);
                }
                else
                {
                    agencies = _agencyRepository.FindAllWithSort(index, count, sort);
                }
                if (Discontinued == false)
                {
                    response.data = agencies.data.ConvertToAgencyViews().Where(x => x.Discontinued == false);
                }
                else
                {
                    response.data = agencies.data.ConvertToAgencyViews();
                }

                response.totalCount = agencies.totalCount;
            }
            catch (Exception ex)
            {
                response.ErrorMessages.Add(ex.Message);
            }

            return(response);
        }
        public GetGeneralResponse <IEnumerable <SupportDeliverServiceView> > GetSupportDeliverServices(int pageSize,
                                                                                                       int pageNumber, IList <FilterData> filter)
        {
            GetGeneralResponse <IEnumerable <SupportDeliverServiceView> > response = new GetGeneralResponse <IEnumerable <SupportDeliverServiceView> >();

            try
            {
                string Filter = FilterUtilityService.GenerateFilterHQLQuery(filter, "SupportDeliverService", null);
                Response <SupportDeliverService> supportDeliverService = _supportDeliverServiceRepository.FindAll(Filter);

                response.data       = supportDeliverService.data.ConvertToSupportDeliverServiceViews();
                response.totalCount = supportDeliverService.totalCount;
            }
            catch (Exception ex)
            {
                response.ErrorMessages.Add(ex.Message);
                if (ex.InnerException != null)
                {
                    response.ErrorMessages.Add(ex.InnerException.Message);
                }
            }

            return(response);
        }
        public GetGeneralResponse <IEnumerable <LocalPhoneStoreView> > GetUnReservedLocalPhoneStores()
        {
            var response = new GetGeneralResponse <IEnumerable <LocalPhoneStoreView> >();

            IList <FilterData> filter = new List <FilterData>();

            filter.Add(new FilterData()
            {
                data = new data()
                {
                    comparison = "eq",
                    type       = "boolean",
                    value      = new [] { bool.FalseString }
                },
                field = "Reserved"
            });
            try
            {
                string query = FilterUtilityService.GenerateFilterHQLQuery(filter, "LocalPhoneStore", null);

                Response <LocalPhoneStore> localPhoneStores = _localPhoneStoreRepository.FindAll(query);

                response.data       = localPhoneStores.data.ConvertToLocalPhoneStoreViews().OrderBy(x => x.LocalPhoneNumber);
                response.totalCount = localPhoneStores.totalCount;
            }
            catch (Exception ex)
            {
                response.ErrorMessages.Add(ex.Message);
                if (ex.InnerException != null)
                {
                    response.ErrorMessages.Add(ex.InnerException.Message);
                }
            }

            return(response);
        }
Beispiel #21
0
        public GetGeneralResponse <IEnumerable <GetSaleDetailReportView> > GetSaleReport(IList <FilterData> filters)
        {
            GetGeneralResponse <IEnumerable <GetSaleDetailReportView> > response =
                new GetGeneralResponse <IEnumerable <GetSaleDetailReportView> >();

            string query = FilterUtilityService.GenerateFilterHQLQuery(filters, "ProductSaleDetail", null);

            Response <ProductSaleDetail> productSaleDetails = _productSaleDetailRepository.FindAll(query);

            IList <GetSaleDetailReportView> Report = new List <GetSaleDetailReportView>();

            foreach (ProductSaleDetail _productSaleDetail in productSaleDetails.data)
            {
                GetSaleDetailReportView item = new GetSaleDetailReportView();
                item.ADSLPhone  = _productSaleDetail.Sale.Customer.ADSLPhone;
                item.CenterName = _productSaleDetail.Sale.Customer.Center == null
                    ? ""
                    : _productSaleDetail.Sale.Customer.Center.CenterName;
                item.Name             = _productSaleDetail.Sale.Customer.Name;
                item.ProductPriceName = _productSaleDetail.ProductPrice.ProductPriceTitle;
                item.ProductName      = _productSaleDetail.ProductPrice.Product.ProductName;
                item.BonusDate        = _productSaleDetail.BonusDate;
                item.ComissionDate    = _productSaleDetail.ComissionDate;

                if (_productSaleDetail.IsRollbackDetail)
                {
                    item.Bonus     = _productSaleDetail.Bonus;
                    item.Comission = _productSaleDetail.Comission;

                    item.DeliverDate         = _productSaleDetail.MainSaleDetail.DeliverDate;
                    item.DeliverEmployeeName = _productSaleDetail.MainSaleDetail.DeliverEmployee == null
                        ? ""
                        : (string)_productSaleDetail.MainSaleDetail.DeliverEmployee.Name;
                    item.Discount             = _productSaleDetail.MainSaleDetail.LineDiscount;
                    item.Imposition           = _productSaleDetail.MainSaleDetail.LineImposition;
                    item.Price                = _productSaleDetail.MainSaleDetail.UnitPrice;
                    item.Count                = _productSaleDetail.MainSaleDetail.Units;
                    item.RollBackEmployeeName = _productSaleDetail.CreateEmployee.Name;
                    item.RollBackPrice        = _productSaleDetail.RollbackPrice;
                    item.RoolBackDate         = _productSaleDetail.CreateDate;
                    item.SaleDate             = _productSaleDetail.MainSaleDetail.CreateDate;
                    item.Total                = _productSaleDetail.LineTotal;
                    item.TotalRollBack        = _productSaleDetail.Units;
                    item.SaleEmployeeName     = _productSaleDetail.MainSaleDetail.CreateEmployee.Name;
                }
                else
                {
                    item.Bonus     = _productSaleDetail.Bonus;
                    item.Comission = _productSaleDetail.Comission;

                    item.DeliverDate         = _productSaleDetail.DeliverDate;
                    item.DeliverEmployeeName = _productSaleDetail.DeliverEmployee == null
                        ? ""
                        : (string)_productSaleDetail.DeliverEmployee.Name;
                    item.Discount         = _productSaleDetail.LineDiscount;
                    item.Imposition       = _productSaleDetail.LineImposition;
                    item.Price            = _productSaleDetail.UnitPrice;
                    item.Count            = _productSaleDetail.Units;
                    item.SaleDate         = _productSaleDetail.CreateDate;
                    item.Total            = _productSaleDetail.LineTotal;
                    item.SaleDate         = _productSaleDetail.Sale.CreateDate;
                    item.SaleEmployeeName = _productSaleDetail.CreateEmployee.Name;
                    item.CustomerID       = _productSaleDetail.Sale.Customer.ID;

                    if (_productSaleDetail.Rollbacked)
                    {
                        Infrastructure.Querying.Query q = new Query();
                        Criterion crt = new Criterion("MainSaleDetail.ID", _productSaleDetail.ID, CriteriaOperator.Equal);
                        q.Add(crt);
                        ProductSaleDetail RollbakedProductSaleDetail = _productSaleDetailRepository.FindBy(q).FirstOrDefault();
                        if (RollbakedProductSaleDetail != null)
                        {
                            item.RollBackEmployeeName = RollbakedProductSaleDetail.CreateEmployee.Name;
                            item.RollBackPrice        = RollbakedProductSaleDetail.LineTotal;
                            item.RoolBackDate         = RollbakedProductSaleDetail.CreateDate;
                            item.TotalRollBack        = RollbakedProductSaleDetail.Units;
                        }
                    }
                }
                Report.Add(item);
            }
            response.data       = Report;
            response.totalCount = Report.Count();
            return(response);
        }
Beispiel #22
0
        public GetGeneralResponse <IEnumerable <SupportView> > GetSupports(int pageSize, int pageNumber,
                                                                           IList <FilterData> filter, IList <Sort> sort, int LastState)
        {
            GetGeneralResponse <IEnumerable <SupportView> > response = new GetGeneralResponse <IEnumerable <SupportView> >();

            try
            {
                int index = (pageNumber - 1) * pageSize;
                int count = pageSize;
                IList <FilterData> Filters = new List <FilterData>();
                if (filter != null)
                {
                    foreach (var item in filter)
                    {
                        Filters.Add(item);
                    }
                }
                if (LastState == 0)
                {
                }
                if (LastState == 1)
                {
                    Filters.Add(new FilterData()
                    {
                        data = new data()
                        {
                            comparison = "eq",
                            type       = "boolean",
                            value      = new[] { bool.TrueString }
                        },
                        field = "SupportStatus.IsLastSupportState"
                    });
                }
                if (LastState == 2)
                {
                    Filters.Add(new FilterData()
                    {
                        data = new data()
                        {
                            comparison = "eq",
                            type       = "boolean",
                            value      = new[] { bool.FalseString }
                        },
                        field = "SupportStatus.IsLastSupportState"
                    });
                }

                string             query    = FilterUtilityService.GenerateFilterHQLQuery(Filters, "Support", sort);
                Response <Support> supports = new Response <Support>();


                supports = _supportRepository.FindAll(query, index, count);

                response.data = supports.data.ConvertToSupportViews();

                response.totalCount = supports.totalCount;
            }
            catch (Exception ex)
            {
                response.ErrorMessages.Add(ex.Message);
                if (ex.InnerException != null)
                {
                    response.ErrorMessages.Add(ex.InnerException.Message);
                }
            }
            return(response);
        }
Beispiel #23
0
        public GetGeneralResponse <IEnumerable <CourierView> > GetAllCouriersByEmployee(int pageSize, int pageNumber,
                                                                                        IList <FilterData> filter, IList <Sort> sort, Guid EmployeeID)
        {
            GetGeneralResponse <IEnumerable <CourierView> > response = new GetGeneralResponse <IEnumerable <CourierView> >();

            try
            {
                int index = (pageNumber - 1) * pageSize;
                int count = pageSize;

                IList <FilterData> _filter = new List <FilterData>();
                if (filter != null)
                {
                    foreach (var filterData in filter)
                    {
                        _filter.Add(filterData);
                    }
                }

                #region Add Customer Filter

                _filter.Add(new FilterData()
                {
                    data = new data()
                    {
                        comparison = "eq",
                        type       = "list",
                        value      = new[] { EmployeeID.ToString() }
                    },
                    field = "CreateEmployee.ID"
                });

                #endregion

                string             query    = FilterUtilityService.GenerateFilterHQLQuery(_filter, "Courier", sort);
                Response <Courier> couriers = _courierRepository.FindAll(query, index, count);

                foreach (var item in couriers.data)
                {
                    long Bonus = 0;
                    if (item.Sale.UncreditSaleDetails.Any())
                    {
                        Bonus += item.Sale.UncreditSaleDetails.Sum(x => x.Bonus);
                    }
                    if (item.Sale.CreditSaleDetails.Any())
                    {
                        Bonus += item.Sale.CreditSaleDetails.Sum(x => x.Bonus);
                    }
                    if (item.Sale.ProductSaleDetails.Any())
                    {
                        Bonus += item.Sale.ProductSaleDetails.Sum(x => x.Bonus);
                    }
                    item.Bonus = Bonus;
                }

                response.data       = couriers.data.ConvertToCourierViews();
                response.totalCount = couriers.totalCount;
            }
            catch (Exception ex)
            {
                response.ErrorMessages.Add(ex.Message);
                if (ex.InnerException != null)
                {
                    response.ErrorMessages.Add(ex.InnerException.Message);
                }
            }

            return(response);
        }
Beispiel #24
0
        public GetGeneralResponse <IEnumerable <SupportOwnView> > GetOwnSupports(Guid EmployeeID, int pageSize, int pageNumber, IList <FilterData> filter, IList <Sort> sort)
        {
            GetGeneralResponse <IEnumerable <SupportOwnView> > response = new GetGeneralResponse <IEnumerable <SupportOwnView> >();

            try
            {
                int index = (pageNumber - 1) * pageSize;
                int count = pageSize;

                IList <FilterData> _filter = new List <FilterData>();

                //_filter.Add(new FilterData()
                //{
                //    data = new data() {
                //        comparison="eq",
                //        type="date",
                //        value=new[]{PersianDateTime.Now.Substring(0,10)}
                //    },
                //    field="DispatchDate"
                //});
                var employees = _employeeService.GetAllChilOfAnEmployee(EmployeeID);

                IList <string> Ids = new List <string>();
                if (employees.data.Any())
                {
                    foreach (var item in employees.data)
                    {
                        Ids.Add(item.ID.ToString());
                    }
                    Ids.Add(EmployeeID.ToString());
                    FilterData Filter = new FilterData();
                    Filter.field = "ExpertEmployee.ID";
                    Filter.data  = new data()
                    {
                        comparison = "eq",
                        type       = "list",
                        value      = Ids.ToArray()
                    };
                    _filter.Add(Filter);
                }
                //_filter.Add(new FilterData()
                //{
                //    data = new data()
                //    {
                //        comparison = "eq",
                //        type = "string",
                //        value = new[] { EmployeeID.ToString() }
                //    },
                //    field = "ExpertEmployee.ID"
                //});
                if (!_filter.Any())
                {
                    _filter.Add(new FilterData()
                    {
                        data = new data()
                        {
                            comparison = "eq",
                            type       = "string",
                            value      = new[] { EmployeeID.ToString() }
                        },
                        field = "ExpertEmployee.ID"
                    });
                }
                if (filter != null)
                {
                    foreach (var item in filter)
                    {
                        _filter.Add(item);
                    }
                }

                string query = FilterUtilityService.GenerateFilterHQLQuery(_filter, "SupportExpertDispatch", sort);

                Response <SupportExpertDispatch> supportExpertDispatch = _supportExpertDispatchRepository.FindAll(query, index, count);



                response.data = supportExpertDispatch.data.ConvertToSupportOwnViews();

                foreach (var item in supportExpertDispatch.data)
                {
                    foreach (var _item in response.data)
                    {
                        if (item.ID == _item.ID)
                        {
                            if (item.Support.Customer.Sales.Where(x => x.ProductSaleDetails.Where(v => v.IsRollbackDetail != true).Where(v => v.Delivered != true).Count() > 0).Count() > 0)
                            {
                                _item.HasNotDeliveredProducts = true;
                            }
                        }
                    }
                }
                response.totalCount = supportExpertDispatch.totalCount;
            }
            catch (Exception ex)
            {
                response.ErrorMessages.Add(ex.Message);
            }

            return(response);
        }
Beispiel #25
0
        public GetGeneralResponse <IEnumerable <ToDoView> > GetReferedEmployeeToDos(Guid CreateEmployeeID, Guid ReferedEmployeeID, int?Close, int?TaskStatusID,
                                                                                    string StartDateRange, string EndDateRange, Guid CustomerID, int pageSize, int pageNumber, IList <Sort> sort)
        {
            GetGeneralResponse <IEnumerable <ToDoView> > response = new GetGeneralResponse <IEnumerable <ToDoView> >();

            #region Temp Code

            //IQueryable<ToDoResult> toDoViews = _toDoResultRepository.FindAll().AsQueryable();

            //if (CreateEmployeeID != Guid.Empty)
            //{
            //    toDoViews = toDoViews.Where(x => x.CreateEmployee.ID == CreateEmployeeID || x.ReferedEmployee.ID == CreateEmployeeID).AsQueryable();
            //}

            //if (ReferedEmployeeID != Guid.Empty)
            //{
            //    toDoViews = toDoViews.Where(x => x.ReferedEmployee.ID == ReferedEmployeeID).AsQueryable();
            //}



            //if (StartDateRange != "")
            //{
            //    toDoViews = toDoViews.Where(x => string.Compare(x.ToDo.StartDate.Substring(0, 10), StartDateRange) >= 0);
            //}
            //if (EndDateRange != "")
            //{
            //    toDoViews = toDoViews.Where(x => string.Compare(x.ToDo.StartDate.Substring(0, 10), EndDateRange) <= 0);
            //}
            //switch (Close)
            //{
            //    case 3:
            //        {
            //            toDoViews = toDoViews.Where(x => x.ToDo.PrimaryClosed == true);
            //            break;
            //        }
            //    case 2:
            //        {
            //            toDoViews = toDoViews.Where(x => x.ToDo.PrimaryClosed == false).Where(x => x.SecondaryClosed == true);
            //            break;
            //        }
            //    case 1:
            //        {
            //            toDoViews = toDoViews.Where(x => x.ToDo.PrimaryClosed == false).Where(x => x.SecondaryClosed == false);
            //            break;
            //        }
            //}
            //if (CustomerID != Guid.Empty)
            //{
            //    toDoViews = toDoViews.Where(x => x.ToDo.Customer.ID == CustomerID);
            //}
            //var tt = toDoViews.Distinct().ConvertToToDoResultViews();


            //response.data = toDoViews.Select(x => x.ToDo).Distinct().ConvertToToDoViews();

            #region Temp
            //try
            //{


            //    int index = (pageNumber - 1) * pageSize;
            //    int count = pageSize;

            //    Infrastructure.Querying.Query query = new Query();
            //    switch (Close)
            //    {
            //        case null:
            //            {
            //                break;
            //            }
            //        //case 1:
            //        //    {
            //        //        Criterion criteriaSecondaryClosed = new Criterion("ToDo.PrimaryClosed", false, CriteriaOperator.Equal);
            //        //        query.Add(criteriaSecondaryClosed);
            //        //        break;
            //        //    }
            //        case 2:
            //            {
            //                Criterion criteriaSecondaryClosed = new Criterion("SecondaryClosed", true, CriteriaOperator.Equal);
            //                query.Add(criteriaSecondaryClosed);
            //                break;
            //            }

            //    }


            //    Response<ToDoResult> toDoResults = _toDoResultRepository.FindBy(query, -1, -1);

            //    IEnumerable<ToDoResult> result = from r in toDoResults.data where r.ReferedEmployee.ID == ReferedEmployeeID || r.CreateEmployee.ID == ReferedEmployeeID select r;

            //    if (count != -1)
            //    {
            //        if (CustomerID != null)
            //            response.data = result.Select(w => w.ToDo).Distinct().ConvertToToDoViews().Skip(index).Take(count).Where(x => x.CustomerID == CustomerID);
            //        else
            //            response.data = result.Select(w => w.ToDo).Distinct().ConvertToToDoViews().Skip(index).Take(count);

            //    }



            //    else
            //    {
            //        if (CustomerID != null)
            //        {
            //            response.data = result.Select(w => w.ToDo).Distinct().ConvertToToDoViews().Where(x => x.CustomerID == CustomerID);
            //            response.totalCount = response.data.Count();
            //        }
            //        else
            //        {
            //            response.data = toDoResults.data.Select(w => w.ToDo).Distinct().ConvertToToDoViews();
            //            response.totalCount = response.data.Count();
            //            if (CreateEmployeeID != null)
            //            {
            //                response.data = response.data.Where(x => x.CreateEmployeeID == CreateEmployeeID);
            //            }
            //        }
            //    }
            //    if (StartDateRange != "")
            //    {
            //        response.data = response.data.Where(w => string.Compare(w.StartDate.Substring(0, 10), StartDateRange) >= 0);
            //    }
            //    if (EndDateRange != "")
            //    {
            //        response.data = response.data.Where(w => string.Compare(w.StartDate.Substring(0, 10), StartDateRange) <= 0);
            //    }

            //    switch (Close)
            //    {
            //        case null:
            //            {
            //                break;
            //            }
            //        case 1:
            //            {
            //                response.data = response.data.Where(x => x.PrimaryClosed == false);
            //                break;
            //            }
            //        case 2:
            //        {

            //            response.data = response.data.Where(x => x.PrimaryClosed == false);

            //                break;
            //            }
            //        case 3:
            //            {
            //                response.data = response.data.Where(x => x.PrimaryClosed == true);

            //                break;
            //            }

            //    }


            //    // اصلاح آدرس عکسها و پاس دادن آدرس جدید

            //    foreach (ToDoView toDo in response.data)
            //    {
            //        //if (ReferedEmployeeID != null)
            //        //{
            //        //    toDo.ToDoResults =
            //        //        toDo.ToDoResults.Where(x => x.ReferedEmployeeID == ReferedEmployeeID);
            //        //}

            //        if (toDo.CreateEmployeeID == ReferedEmployeeID)
            //        {
            //            toDo.IsMine = true;
            //        }
            //        if(toDo.Attachment!=null)
            //        toDo.Attachment = toDo.Attachment.Replace(@"\", "/").Substring(toDo.Attachment.IndexOf("data")); ;
            //    }

            //    int counter=0;
            //    IList<ToDoView> finalData=new List<ToDoView>();
            //    foreach (ToDoView toDo in response.data)
            //    {
            //        if(toDo.ToDoResults.Count()>0)
            //            finalData.Add(toDo);

            //    }
            //    response.data = finalData;
            //}

            //catch (Exception ex)
            //{
            //    response.ErrorMessages.Add(ex.Message);
            //    if (ex.InnerException != null)
            //        response.ErrorMessages.Add(ex.InnerException.Message);
            //}



            //}
            #endregion

            #endregion

            #region preparing Filters

            IList <FilterData> filters = new List <FilterData>();

            if (ReferedEmployeeID == Guid.Empty)
            {
                filters.Add(new FilterData()
                {
                    data = new data()
                    {
                        type       = "list",
                        comparison = "eq",
                        value      = new[] { CreateEmployeeID.ToString() }
                    },
                    field = "ToDo.CreateEmployee.ID"
                });
            }

            if (ReferedEmployeeID != Guid.Empty)
            {
                filters.Add(new FilterData()
                {
                    data = new data()
                    {
                        type       = "list",
                        comparison = "eq",
                        value      = new[] { CreateEmployeeID.ToString() }
                    },
                    field = "ReferedEmployee.ID"
                });
            }

            if (Close == 1)
            {
                filters.Add(new FilterData()
                {
                    data = new data()
                    {
                        type       = "boolean",
                        comparison = "eq",
                        value      = new[] { bool.FalseString }
                    },
                    field = "SecondaryClosed"
                });

                filters.Add(new FilterData()
                {
                    data = new data()
                    {
                        type       = "boolean",
                        comparison = "eq",
                        value      = new[] { bool.FalseString }
                    },
                    field = "ToDo.PrimaryClosed"
                });
            }

            if (Close == 2)
            {
                filters.Add(new FilterData()
                {
                    data = new data()
                    {
                        type       = "boolean",
                        comparison = "eq",
                        value      = new[] { bool.TrueString }
                    },
                    field = "SecondaryClosed"
                });

                filters.Add(new FilterData()
                {
                    data = new data()
                    {
                        type       = "boolean",
                        comparison = "eq",
                        value      = new[] { bool.FalseString }
                    },
                    field = "ToDo.PrimaryClosed"
                });
            }

            if (Close == 3)
            {
                filters.Add(new FilterData()
                {
                    data = new data()
                    {
                        type       = "boolean",
                        comparison = "eq",
                        value      = new[] { bool.TrueString }
                    },
                    field = "ToDo.PrimaryClosed"
                });
            }

            #region Payment Date

            if (StartDateRange != null && EndDateRange == null)
            {
                FilterData Filter = new FilterData()
                {
                    field = "ToDo.StartDate",
                    data  = new data()
                    {
                        comparison = "gteq",
                        type       = "date",
                        value      = new[] { StartDateRange }
                    }
                };
                filters.Add(Filter);
            }

            if (EndDateRange != null && StartDateRange == null)
            {
                FilterData Filter = new FilterData()
                {
                    field = "ToDo.StartDate",
                    data  = new data()
                    {
                        comparison = "lteq",
                        type       = "date",
                        value      = new[] { EndDateRange }
                    }
                };
                filters.Add(Filter);
            }

            if (StartDateRange != null && EndDateRange != null)
            {
                FilterData Filter = new FilterData()
                {
                    field = "ToDo.StartDate",
                    data  = new data()
                    {
                        comparison = "gteq",
                        type       = "date",
                        value      = new[] { StartDateRange }
                    }
                };
                filters.Add(Filter);
            }
            #endregion

            string query = FilterUtilityService.GenerateFilterHQLQuery(filters, "ToDoResult", null);

            //if (StartDateRange != null && EndDateRange != null)
            //{
            //    response.data =
            //        _toDoResultRepository.FindAll(query)
            //            .data.Select(x => x.ToDo)
            //            .Distinct()
            //            .Where(x => string.Compare(x.EndDate.Substring(0, 10), EndDateRange) >= 0)
            //            .ConvertToToDoViews();
            //}

            IEnumerable <ToDoResult> res = _toDoResultRepository.FindAll(query).data;

            response.data = _toDoResultRepository.FindAll(query).data.Select(x => x.ToDo).Distinct().ConvertToToDoViews();



            #endregion

            return(response);
        }
Beispiel #26
0
        public GetGeneralResponse <IEnumerable <GetBankCasheReportView> > GetBankCasheReport(int?TransactionType, IEnumerable <Guid> MoneyAccountID,
                                                                                             string InvestStartDate, string InvestEndDate, string ConfirmStartDate, string ConfirmEndDate, IList <Sort> sort, bool NotConfirmed)
        {
            GetGeneralResponse <IEnumerable <GetBankCasheReportView> > response = new GetGeneralResponse <IEnumerable <GetBankCasheReportView> >();

            try
            {
                #region Preparing Filters

                IList <FilterData> filters = new List <FilterData>();

                if (NotConfirmed == true)
                {
                    FilterData TransactionTypeFilter = new FilterData()
                    {
                        field = "Confirm",
                        data  = new data()
                        {
                            type       = "numeric",
                            comparison = "eq",
                            value      = new[] { "3" }
                        }
                    };
                    filters.Add(TransactionTypeFilter);
                }
                if (NotConfirmed == false)
                {
                    FilterData TransactionTypeFilter = new FilterData()
                    {
                        field = "Confirm",
                        data  = new data()
                        {
                            type       = "numeric",
                            comparison = "eq",
                            value      = new[] { "2" }
                        }
                    };
                    filters.Add(TransactionTypeFilter);
                }

                #region Transaction Type
                if (TransactionType == 1)
                {
                    FilterData TransactionTypeFilter = new FilterData()
                    {
                        field = "Cost",
                        data  = new data()
                        {
                            type       = "numeric",
                            comparison = "gt",
                            value      = new[] { "0" }
                        }
                    };
                    filters.Add(TransactionTypeFilter);
                }

                if (TransactionType == 2)
                {
                    FilterData TransactionTypeFilter = new FilterData()
                    {
                        field = "Cost",
                        data  = new data()
                        {
                            type       = "numeric",
                            comparison = "lt",
                            value      = new[] { "0" }
                        }
                    };
                    filters.Add(TransactionTypeFilter);
                }
                #endregion

                #region MoneyAccount

                if (MoneyAccountID != null)
                {
                    FilterData MoneyAccounFilter = new FilterData()
                    {
                        field = "MoneyAccountName",
                        data  = new data()
                        {
                            type  = "list",
                            value = MoneyAccountID.Select(x => x.ToString()).ToArray(),
                        }
                    };
                    filters.Add(MoneyAccounFilter);
                }

                #endregion

                #region Invest Start Date

                if (InvestStartDate != null && InvestEndDate == null)
                {
                    FilterData InvestStartDateFilter = new FilterData()
                    {
                        field = "InvestDate",
                        data  = new data()
                        {
                            comparison = "gteq",
                            type       = "dateOnly",
                            value      = new[] { InvestStartDate }
                        }
                    };
                    filters.Add(InvestStartDateFilter);
                }

                #endregion

                #region Invest End Date

                if (InvestEndDate != null && InvestStartDate == null)
                {
                    FilterData InvestEndDateFilter = new FilterData()
                    {
                        field = "InvestDate",
                        data  = new data()
                        {
                            comparison = "lteq",
                            type       = "dateOnly",
                            value      = new[] { InvestEndDate }
                        }
                    };
                    filters.Add(InvestEndDateFilter);
                }

                if (InvestEndDate != null & InvestStartDate != null)
                {
                    FilterData ConfirmEndDateFilter = new FilterData()
                    {
                        field = "InvestDate",
                        data  = new data()
                        {
                            comparison = "lteq",
                            type       = "dateOnlyBetween",
                            value      = new[] { InvestStartDate, InvestEndDate }
                        }
                    };
                    filters.Add(ConfirmEndDateFilter);
                }

                #endregion

                #region Confirem Start Date

                if (ConfirmStartDate != null && ConfirmEndDate == null)
                {
                    FilterData ConfirmStartDateFilter = new FilterData()
                    {
                        field = "ConfirmDate",
                        data  = new data()
                        {
                            comparison = "gteq",
                            type       = "date",
                            value      = new[] { ConfirmStartDate }
                        }
                    };
                    filters.Add(ConfirmStartDateFilter);
                }

                #endregion

                #region Confirem End Date

                if (ConfirmEndDate != null & ConfirmStartDate == null)
                {
                    FilterData ConfirmEndDateFilter = new FilterData()
                    {
                        field = "ConfirmDate",
                        data  = new data()
                        {
                            comparison = "lteq",
                            type       = "date",
                            value      = new[] { ConfirmStartDate }
                        }
                    };
                    filters.Add(ConfirmEndDateFilter);
                }

                if (ConfirmEndDate != null & ConfirmStartDate != null)
                {
                    if (ConfirmEndDate == ConfirmStartDate)
                    {
                        FilterData ConfirmEndDateFilter = new FilterData()
                        {
                            field = "ConfirmDate",
                            data  = new data()
                            {
                                comparison = "eq",
                                type       = "date",
                                value      = new[] { ConfirmStartDate }
                            }
                        };
                        filters.Add(ConfirmEndDateFilter);
                    }
                    else
                    {
                        FilterData ConfirmEndDateFilter = new FilterData()
                        {
                            field = "ConfirmDate",
                            data  = new data()
                            {
                                comparison = "lteq",
                                type       = "dateBetween",
                                value      = new[] { ConfirmStartDate, ConfirmEndDate }
                            }
                        };
                        filters.Add(ConfirmEndDateFilter);
                    }
                }

                #region فقط فاکتور های تایید شده

                FilterData ConfirmedFilter = new FilterData()
                {
                    field = "Confirm",
                    data  = new data()
                    {
                        type       = "numeric",
                        comparison = "eq",
                        value      = new[] { "2" }
                    }
                };

                filters.Add(ConfirmedFilter);

                #endregion

                #endregion


                #endregion

                string query = FilterUtilityService.GenerateFilterHQLQuery(filters, "Fiscal", sort);

                Response <Fiscal> fiscals = _fiscalRepository.FindAll(query);

                #region Preparing Report View

                IList <GetBankCasheReportView> report = new List <GetBankCasheReportView>();

                foreach (Fiscal fiscal in fiscals.data)
                {
                    GetBankCasheReportView _report = new GetBankCasheReportView();

                    _report.ADSLPhone = fiscal.Customer.ADSLPhone;
                    _report.Bes       = fiscal.Cost > 0 ? "بستانکار" : "";
                    _report.Bed       = fiscal.Cost < 0 ? "بدهکار" : "";

                    _report.ConfiremdCost = fiscal.ConfirmedCost == null ? 0 : (long)fiscal.ConfirmedCost;
                    _report.ConfirmDate   = fiscal.ConfirmDate;
                    if (fiscal.ConfirmEmployee != null)
                    {
                        _report.ConfirmEmployeeName = fiscal.ConfirmEmployee.Name;
                    }
                    _report.Cost = fiscal.Cost;
                    _report.CreateEmployeeName = fiscal.CreateEmployee.Name;
                    _report.InvestDate         = fiscal.InvestDate;
                    _report.Name                   = fiscal.Customer.Name;
                    _report.SerialNumber           = fiscal.SerialNumber;
                    _report.MoneyAccountName       = fiscal.MoneyAccount.AccountName;
                    _report.Note                   = fiscal.Note;
                    _report.AccountingSerialNumber = fiscal.DocumentSerial;
                    _report.FiscalReciptNumber     = fiscal.FiscalReciptNumber;

                    #region Preparing DOC Type
                    int docType = (int)fiscal.DocumentType;
                    if (docType == 1)
                    {
                        _report.DocType = "رسید عابر بانک";
                    }
                    else if (docType == 2)
                    {
                        _report.DocType = "فیش بانکی";
                    }
                    else if (docType == 3)
                    {
                        _report.DocType = "چک";
                    }
                    else if (docType == 4)
                    {
                        _report.DocType = "قبض صندوق";
                    }
                    else if (docType == 5)
                    {
                        _report.DocType = "رسید POS";
                    }
                    else if (docType == 6)
                    {
                        _report.DocType = "پرداخت اینترنتی";
                    }
                    else if (docType == 7)
                    {
                        _report.DocType = "سایت ماهان";
                    }
                    else if (docType == 8)
                    {
                        _report.DocType = "سایر موارد";
                    }

                    #endregion
                    report.Add(_report);
                }

                #endregion

                response.data       = report;
                response.totalCount = report.Count();
            }
            catch (Exception ex)
            {
                response.ErrorMessages.Add(ex.Message);
                if (ex.InnerException != null)
                {
                    response.ErrorMessages.Add(ex.InnerException.Message);
                }
            }

            return(response);
        }