예제 #1
0
        public IEnumerable <VehicleViewModels> GetVehicleView(FilterDates date, List <string> FilterTypes = null, List <string> FilterColors = null)
        {
            FilterViewModels         filters          = new FilterViewModels();
            List <Vehicle>           TempVehicles     = new List <Vehicle>();
            List <VehicleViewModels> SelectedVehicles = new List <VehicleViewModels>();
            DateTime FromDate;
            DateTime ToDate;
            DateTime Today = DateTime.Now;

            switch (date)
            {
            case FilterDates.Today:
                FromDate = new DateTime(Today.Year, Today.Month, Today.Day, 0, 0, 0);
                ToDate   = new DateTime(Today.Year, Today.Month, Today.Day, 23, 59, 59);
                break;

            case FilterDates.Week:
                int x = Today.Day - (Today.Day % 7);
                FromDate = new DateTime(Today.Year, Today.Month, x);
                ToDate   = new DateTime(Today.Year, Today.Month, x + 7);
                break;

            case FilterDates.Month:
                FromDate = new DateTime(Today.Year, Today.Month, 1);
                ToDate   = new DateTime(Today.Year, Today.Month, DateTime.DaysInMonth(Today.Year, Today.Month));
                break;

            default:
                FromDate = new DateTime(1970, 1, 1);
                ToDate   = new DateTime(Today.Year + 3, Today.Month, Today.Day);
                break;
            }


            if (FilterColors.Count() == 0)
            {
                FilterColors = filters.VehicleColors.Keys.ToList();
            }

            TempVehicles = db.Vehicles.ToList().Where(o => FilterTypes.Contains(Enum.GetName(typeof(VehicleType), o.VehicleType).ToString()) &&
                                                      FilterColors.Contains(Enum.GetName(typeof(VehicleColors), o.Color).ToString())).ToList();

            foreach (var item in TempVehicles)
            {
                SelectedVehicles.Add(new VehicleViewModels
                {
                    Owner       = item.Owner_ID,
                    RegNum      = item.Vehicle_ID,
                    Color       = ((VehicleColors)item.Color).ToString(),
                    VehicleType = ((VehicleType)item.VehicleType).ToString()
                });
            }

            return(SelectedVehicles);
        }
예제 #2
0
        public async Task <IEnumerable <TransactionDto> > GetTransactionsByDatePeriod(FilterDates filter)
        {
            var query = await _context.Transactions
                        .Include(c => c.PaymentDetails)
                        .Select(c => c)
                        .Where(c => (filter.FromDate.HasValue && c.TransactionDate > filter.FromDate) &&
                               (filter.ToDate.HasValue && c.TransactionDate < filter.ToDate)).ToListAsync();

            return(query);
        }
예제 #3
0
        public async Task <IActionResult> GetByDate([FromBody] FilterDates filter)
        {
            var result = await _service.GetTransactionsByDatePeriod(filter);

            return(Ok(result));
        }
예제 #4
0
 public Utility.AngularElements.CheckBox FilterCreatedDate(FilterDates filterDate)
 {
     return(new Utility.AngularElements.CheckBox(browser.FindId("createdDate" + filterDate)));
 }
예제 #5
0
 public async Task <IEnumerable <TransactionDto> > GetTransactionsByDatePeriod(FilterDates filter)
 {
     return(await _repository.GetTransactionsByDatePeriod(filter));
 }