public ActionResult Events(int? planetID,
                                   int? accountID,
                                   int? springBattleID,
                                   int? clanID,
                                   int? factionID,
                                   string filter,
                                   int pageSize = 0,
                                   int page = 0,
                                   bool partial = false)
        {
            var db = new ZkDataContext();
            if (Request.IsAjaxRequest()) partial = true;
            if (pageSize == 0)
            {
                if (!partial) pageSize = 40;
                else pageSize = 10;
            }
            IQueryable<Event> res = db.Events.AsQueryable();
            if (planetID.HasValue) res = res.Where(x => x.Planets.Any(y => y.PlanetID == planetID));
            if (accountID.HasValue) res = res.Where(x => x.Accounts.Any(y => y.AccountID == accountID));
            if (clanID.HasValue) res = res.Where(x => x.Clans.Any(y => y.ClanID == clanID));
            if (springBattleID.HasValue) res = res.Where(x => x.SpringBattles.Any(y => y.SpringBattleID == springBattleID));
            if (factionID.HasValue) res = res.Where(x => x.Factions.Any(y => y.FactionID == factionID));
            if (!string.IsNullOrEmpty(filter)) res = res.Where(x => x.Text.Contains(filter));
            res = res.OrderByDescending(x => x.EventID);

            var ret = new EventsResult
                      {
                          PageCount = (res.Count() / pageSize) + 1,
                          Page = page,
                          Events = res.Skip(page * pageSize).Take(pageSize),
                          PlanetID = planetID,
                          AccountID = accountID,
                          SpringBattleID = springBattleID,
                          Filter = filter,
                          ClanID = clanID,
                          Partial = partial,
                          PageSize = pageSize
                      };

            return View(ret);
        }
예제 #2
0
        public ActionResult Events(int?planetID,
                                   int?accountID,
                                   int?springBattleID,
                                   int?clanID,
                                   int?factionID,
                                   string filter,
                                   int pageSize = 0,
                                   int page     = 0,
                                   bool partial = false)
        {
            var db = new ZkDataContext();

            if (Request.IsAjaxRequest())
            {
                partial = true;
            }
            if (pageSize == 0)
            {
                if (!partial)
                {
                    pageSize = 40;
                }
                else
                {
                    pageSize = 10;
                }
            }
            IQueryable <Event> res = db.Events.AsQueryable();

            if (planetID.HasValue)
            {
                res = res.Where(x => x.Planets.Any(y => y.PlanetID == planetID));
            }
            if (accountID.HasValue)
            {
                res = res.Where(x => x.Accounts.Any(y => y.AccountID == accountID));
            }
            if (clanID.HasValue)
            {
                res = res.Where(x => x.Clans.Any(y => y.ClanID == clanID));
            }
            if (springBattleID.HasValue)
            {
                res = res.Where(x => x.SpringBattles.Any(y => y.SpringBattleID == springBattleID));
            }
            if (factionID.HasValue)
            {
                res = res.Where(x => x.Factions.Any(y => y.FactionID == factionID));
            }
            if (!string.IsNullOrEmpty(filter))
            {
                res = res.Where(x => x.Text.Contains(filter));
            }
            res = res.OrderByDescending(x => x.EventID);

            var ret = new EventsResult
            {
                PageCount      = (res.Count() / pageSize) + 1,
                Page           = page,
                Events         = res.Skip(page * pageSize).Take(pageSize),
                PlanetID       = planetID,
                AccountID      = accountID,
                SpringBattleID = springBattleID,
                Filter         = filter,
                ClanID         = clanID,
                Partial        = partial,
                PageSize       = pageSize
            };

            return(View(ret));
        }