예제 #1
0
 public ActionResult Heats(int HeatSheetEventID)
 {
     ViewHeats vhs = new ViewHeats();
     try
     {
         vhs = DataCache.Get<ViewHeats>("Heats" + HeatSheetEventID.ToString(), () => GetHeats(HeatSheetEventID));
     }
     catch (Exception ex)
     {
         LogController.LogError(ex, LogEntryType.NormalError, "", "", "SystemUserID=" + base.CurrentUser.SystemUserID.ToString(), "HeatSheetEventID=" + HeatSheetEventID.ToString());
     }
     return PartialView("_Heats", vhs);
 }
예제 #2
0
        //TODO:  Get this out of basecontroller
        protected ViewHeats GetHeats(int HeatSheetEventID)
        {
            ViewHeats vhs = new ViewHeats();
            ViewHeat vh;
            HeatCollection heats = BizMgr.GetHeatsByHeatSheetEventID(HeatSheetEventID);

            SwimMeet sm = BizMgr.GetSwimMeetByHeatSheetEventID(HeatSheetEventID);
            SwimMeetCollection swimMeets = BizMgr.GetSwimMeetsBySystemUserID(this.CurrentUser.SystemUserID);
            var smAdmin = swimMeets.Where<SwimMeet>(vl => vl.SwimMeetID == sm.SwimMeetID && vl.IsAdmin);
            vhs.IsAdmin = smAdmin.Count() > 0;

            int laneCount = 1;
            bool isRelay = false;
            if (heats.Count > 0)
            {
                PoolConfig poolConfig = BizMgr.GetPoolConfigByHeatID(heats[0].HeatID);
                laneCount = poolConfig.LaneCount;
                Stroke stroke = BizMgr.GetStrokeByHeatID(heats[0].HeatID);
                isRelay = stroke.IsRelay;
            }

            List<ViewHeatSwimmer> vhss = new List<ViewHeatSwimmer>();
            foreach (Heat heat in heats)
            {
                vh = new ViewHeat();
                vh.HeatID = heat.HeatID;
                vh.HeatNumber = heat.HeatNumber;
                vh.LaneCount = laneCount;
                vh.IsRelay = isRelay;
                vh.HeatSheetEventID = heat.HeatSheetEventID;
                vhss = GetHeatSwimmers(heat.HeatID);
                if (vhss.Count > 0)
                {
                    vh.ViewHeatSwimmers.AddRange(vhss);
                }
                vhs.ViewHeatList.Add(vh);
            }
            return vhs;
        }