예제 #1
0
        public async Task <DashboardCountDto> GetCountsForDashboard(int userId)
        {
            DashboardCountDto dashboardCountDto = new DashboardCountDto();

            using (var conn = new SqlConnection(_config["ConnectionStrings:DefaultConnection"]))
            {
                var cmd = new SqlCommand("pr_getCountsForDashboard", conn);
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.Parameters.Add(new SqlParameter("@userId", userId));

                conn.Open();
                await using (SqlDataReader reader = await cmd.ExecuteReaderAsync())
                {
                    while (reader.Read())
                    {
                        dashboardCountDto.TotalWorkOrders    = reader.GetInt32(reader.GetOrdinal("TotalWorkOrders"));
                        dashboardCountDto.AssignedWorkOrders = reader.GetInt32(reader.GetOrdinal("AssignedWorkOrders"));
                        dashboardCountDto.AgeTwoWeeks        = reader.GetInt32(reader.GetOrdinal("AgeTwoWeeks"));
                        dashboardCountDto.Unassigned         = reader.GetInt32(reader.GetOrdinal("Unassigned"));
                    }
                }
            }

            return(dashboardCountDto);
        }
예제 #2
0
        public IDashboardCountDto GetAppInfoCountByCityId(Guid cityId)
        {
            var dashboardCount = new DashboardCountDto
            {
                CustomerActiveCount   = _personRepository.AsQuery().OfType <Customer>().Count(p => p.IsActive && p.DefultCustomerAddress.CityId != null && p.DefultCustomerAddress.CityId == cityId),
                CustomerDeActiveCount = _personRepository.AsQuery().OfType <Customer>().Count(p => !p.IsActive && p.DefultCustomerAddress.CityId != null && p.DefultCustomerAddress.CityId == cityId),
                ShopActiveCount       = _personRepository.AsQuery().OfType <Shop>().Count(p => p.IsActive && p.ShopAddress.CityId == cityId),
                ShopDeActiveCount     = _personRepository.AsQuery().OfType <Shop>().Count(p => p.IsActive == false && p.ShopAddress.CityId == cityId),
                FactorPaidCount       = _factorRepository.AsQuery().Count(p => p.FactorState == FactorState.Paid && p.FactorAddress.CityId == cityId),
                FactorPendingCount    = _factorRepository.AsQuery().Count(p => p.FactorState != FactorState.Paid && p.FactorAddress.CityId == cityId)
            };

            return(dashboardCount);
        }