Пример #1
0
        public ActionResult SaveSwimMeet(ViewSwimMeet viewSwimMeet)
        {
            try
            {
                //Save SwimMeet
                SwimMeet swimMeet = new SwimMeet();
                swimMeet.SwimMeetID = viewSwimMeet.SwimMeetID;
                swimMeet.SwimMeetTypeID = viewSwimMeet.SwimMeetTypeID;
                swimMeet.Description = viewSwimMeet.Description;
                swimMeet.StartDate = viewSwimMeet.StartDate;
                swimMeet.EndDate = viewSwimMeet.EndDate;
                swimMeet.LocationID = viewSwimMeet.LocationID;
                swimMeet.SeasonID = viewSwimMeet.SeasonID;
                swimMeet.SwimMeetID = BizMgr.SaveSwimMeet(swimMeet, base.CurrentUser.SystemUserID);

                //Delete existing SwimMeetTeams
                BizMgr.DeleteSwimMeetTeamsBySwimMeetID(swimMeet.SwimMeetID);

                //Save SwimMeetTeams
                SwimMeetTeam smt = null;
                foreach (int teamSeasonID in viewSwimMeet.TeamSeasonIDs)
                {
                    smt = new SwimMeetTeam();
                    smt.SwimMeetID = swimMeet.SwimMeetID;
                    smt.TeamSeasonID = teamSeasonID;
                    BizMgr.SaveSwimMeetTeam(smt);
                }
            }
            catch (Exception ex)
            {
                LogController.LogError(ex, LogEntryType.NormalError, "", "", "SystemUserID=" + base.CurrentUser.SystemUserID.ToString(), "");
            }
            return PartialView("_SwimMeets", GetSwimMeets(base.CurrentUser.SystemUserID));
        }
        public int SaveSwimMeet(SwimMeet swimMeet, int SystemUserID)
        {
            bool isNew = (swimMeet.SwimMeetID == 0);
            int swimMeetID = Ctx.SwimMeetManager.SwimMeetSave(swimMeet);

            //if this is a new swimMeet, create userteam record for the user that created the meeet
            if (isNew)
            {
                //create a UserSwimMeet for each Team Admin on the Teams involved in the meet
                SwimMeetTeamCollection swimMeetTeams = Ctx.SwimMeetTeamManager.SwimMeetTeamGetAllBySwimMeetID(swimMeetID);
                foreach (SwimMeetTeam smt in swimMeetTeams)
                {
                    UserTeamCollection uts = Ctx.UserTeamManager.UserTeamGetAllByTeamSeasonID(smt.TeamSeasonID);
                    foreach (UserTeam ut in uts)
                    {
                        UserSwimMeet usm = new UserSwimMeet();
                        usm.SystemUserID = ut.SystemUserID;
                        usm.SwimMeetID = swimMeetID;
                        Ctx.UserSwimMeetManager.UserSwimMeetSave(usm);
                    }
                }
            }
            return swimMeetID;
        }