public OverallResultByGameFilter(GameFilter gameFilter, List<UserResult> userResults)
        {
            if (gameFilter == null) throw new ArgumentNullException("gameFilter");
            if (userResults == null) throw new ArgumentNullException("userResults");

            if (userResults.Count == 0)
            {
                //userResults.Add(new UserResult(){
            }
            else
            {
                foreach (var userResult in userResults)
                {
                    if (gameFilter.GameFilterId != userResult.GameFilterId)
                    {
                        throw new ArgumentException(
                                        string.Format("gameFilter.GameFilterId:{0} does not match userResult.GameFilterId:{1}",
                                        gameFilter.GameFilterId,
                                        userResult.GameFilterId));
                    }
                }
            }
            GameFilter = gameFilter;
            UserResults = userResults;
            Places = new List<int>();
        }
Esempio n. 2
0
        public GameFilter GetGameFilterByDate(List <GameFilter> gameFilters, DateTime searchDate)
        {
            GameFilter gameFilter = gameFilters.FirstOrDefault(gf => gf.GameFilterStartDate <= searchDate && gf.GameFilterEndDate >= searchDate);

            if (gameFilter == null)
            {
                gameFilter = gameFilters.Last(_ => _.GameFilterAvailable == true);
            }
            return(gameFilter);
        }
Esempio n. 3
0
        public ActionResult Create(GameFilter gamefilter)
        {
            if (ModelState.IsValid)
            {
                db.GameFilters.Add(gamefilter);
                db.SaveChanges();
                return RedirectToAction("Index");
            }

            return View(gamefilter);
        }
Esempio n. 4
0
 public ActionResult Edit(GameFilter gamefilter)
 {
     if (ModelState.IsValid)
     {
         db.Entry(gamefilter).State = EntityState.Modified;
         db.SaveChanges();
         return RedirectToAction("Index");
     }
     return View(gamefilter);
 }