コード例 #1
0
        public IActionResult Index()
        {
            List <StationModel> stationsList = new List <StationModel>();

            try
            {
                using (sedatContext db = new sedatContext())
                {
                    db.Stations.ToList().ForEach(x => stationsList.Add(new StationModel()
                    {
                        Id        = x.Id,
                        AreaId    = x.AreaId,
                        Name      = x.Name,
                        StartDate = x.StartDate.GetValueOrDefault().ToString("dd.MM.yyyy"),
                        score     = x.Score.GetValueOrDefault()
                    }));
                    foreach (var item in stationsList)
                    {
                        item.VillageName  = db.Areas.FirstOrDefault(x => x.Id == item.AreaId).Name;
                        item.TribuneCount = db.Tribunes.Count(x => x.StationId == item.Id);
                    }
                }
            }
            catch
            {
                throw;
            }
            return(View(stationsList));
        }
コード例 #2
0
        public JsonResult SomaResult()
        {
            Earnings earnings = new Earnings()
            {
                StationId = 1
            };

            try
            {
                using (sedatContext db = new sedatContext())
                {
                    db.EarningMonthly.Where(x => x.StationId == earnings.StationId).ToList().ForEach(x => earnings.monthList.Add(new Earnings.List()
                    {
                        Earning = x.Earning.GetValueOrDefault(),
                        Month   = x.Month.GetValueOrDefault()
                    }));
                }
            }
            catch
            {
                throw;
            }
            return(Json(new { earnings = earnings }));
        }