Beispiel #1
0
        /// <summary>
        /// 通过扫码得知该停车场对应信息
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public RequestResult <ScanCodeResult> GetScanCodeResult(CarParkGetViewModel model)
        {
            var result = RequestResult <ScanCodeResult> .Get();

            var week = DateTime.Now.DayOfWeek.ToString();

            TimeSpan timeSpanNow = TimeSpan.Parse(DateTime.Now.ToString("HH:mm"));

            switch (week)
            {
            case "Monday":
                var monlist = (from cps in _carParkSettingRepo.Table
                               join set in _monSettingRepo.Table
                               on cps.qrInfo equals set.qrInfo
                               where (timeSpanNow > set.timeStart && timeSpanNow < set.timeEnd && set.qrInfo == model.qrInfo)
                               select new ScanCodeResult
                {
                    carParkName = cps.carParkName,
                    price = set.price,
                    qrInfo = cps.qrInfo,
                }).FirstOrDefault();
                result.result = monlist;
                break;

            case "Tuesday":
                var tueslist = (from cps in _carParkSettingRepo.Table
                                join set in _tuesSettingRepo.Table
                                on cps.qrInfo equals set.qrInfo
                                where (timeSpanNow > set.timeStart && timeSpanNow < set.timeEnd && set.qrInfo == model.qrInfo)
                                select new ScanCodeResult
                {
                    carParkName = cps.carParkName,
                    price = set.price,
                    qrInfo = cps.qrInfo,
                }).FirstOrDefault();
                result.result = tueslist;
                break;

            case "Wednesday":
                var wedlist = (from cps in _carParkSettingRepo.Table
                               join set in _wedSettingRepo.Table
                               on cps.qrInfo equals set.qrInfo
                               where (timeSpanNow > set.timeStart && timeSpanNow < set.timeEnd && set.qrInfo == model.qrInfo)
                               select new ScanCodeResult
                {
                    carParkName = cps.carParkName,
                    price = set.price,
                    qrInfo = cps.qrInfo,
                }).FirstOrDefault();
                result.result = wedlist;
                break;

            case "Thursday":
                var thurlist = from cps in _carParkSettingRepo.Table
                               join set in _thurSettingRepo.Table
                               on cps.qrInfo equals set.qrInfo
                               where (timeSpanNow > set.timeStart && timeSpanNow < set.timeEnd && set.qrInfo == model.qrInfo)
                               select new ScanCodeResult
                {
                    carParkName = cps.carParkName,
                    price       = set.price,
                    qrInfo      = cps.qrInfo,
                };
                result.result = thurlist.FirstOrDefault();
                break;

            case "Friday":
                var frilist = from cps in _carParkSettingRepo.Table
                              join set in _friSettingRepo.Table
                              on cps.qrInfo equals set.qrInfo
                              where (timeSpanNow > set.timeStart && timeSpanNow < set.timeEnd && set.qrInfo == model.qrInfo)
                              select new ScanCodeResult
                {
                    carParkName = cps.carParkName,
                    price       = set.price,
                    qrInfo      = cps.qrInfo,
                };
                result.result = frilist.FirstOrDefault();
                break;

            case "Saturday":
                var satlist = from cps in _carParkSettingRepo.Table
                              join set in _satSettingRepo.Table
                              on cps.qrInfo equals set.qrInfo
                              where (timeSpanNow > set.timeStart && timeSpanNow < set.timeEnd && set.qrInfo == model.qrInfo)
                              select new ScanCodeResult
                {
                    carParkName = cps.carParkName,
                    price       = set.price,
                    qrInfo      = cps.qrInfo,
                };
                result.result = satlist.FirstOrDefault();
                break;

            case "Sunday":
                var sunlist = from cps in _carParkSettingRepo.Table
                              join set in _sunSettingRepo.Table
                              on cps.qrInfo equals set.qrInfo
                              where (timeSpanNow > set.timeStart && timeSpanNow < set.timeEnd && set.qrInfo == model.qrInfo)
                              select new ScanCodeResult
                {
                    carParkName = cps.carParkName,
                    price       = set.price,
                    qrInfo      = cps.qrInfo,
                };
                result.result = sunlist.FirstOrDefault();
                break;
            }

            return(result);
        }
Beispiel #2
0
 public RequestResult <ScanCodeResult> GetScanCodeResult(CarParkGetViewModel model)
 {
     return(F(() => _carParkService.GetScanCodeResult(model)));
 }