예제 #1
0
파일: ColorVM.cs 프로젝트: rsalit/CSBC
 public static void Insert(Color entity)
 {
     using (var db = new CSBCDbContext())
     {
         var rep = new ColorRepository(db);
         rep.Insert(entity);
         db.SaveChanges();
     }
 }
예제 #2
0
파일: TestInit.cs 프로젝트: rsalit/CSBC
 public void InitColors(CSBCDbContext context)
 {
     var rep = new ColorRepository(context);
     for (int i = 0; i < ColorNames.Count; i++)
     {
         rep.Insert(new Color { ColorName = ColorNames[i], CompanyID = 1 });
     }
     rep.Insert(new Color { ColorName = "Chartreuse", CompanyID = 1, Discontinued = true });
     context.SaveChanges();
 }
예제 #3
0
파일: Games1.aspx.cs 프로젝트: rsalit/CSBC
        private void UpdateRegularSeasonGame(int scheduleNo, int gameNo)
        {
            var vm = new ScheduleGamesVM();
            var game = vm.GetByScheduleAndGameNo(scheduleNo, gameNo);

            try
            {
                game.GameDate = (DateTime)ConcatDateTime(mskDate.Text, txtTime.Text);
                game.GameTime = txtTime.Text;
                game.LocationNumber = Convert.ToInt32(cmbVenues.SelectedItem.Value);
                game.HomeTeamNumber = (int)ScheduleGamesVM.GetScheduleTeamNumberFromTeamNumber(scheduleNo, Convert.ToInt32(txtHome.Text));
                game.VisitingTeamNumber = (int)ScheduleGamesVM.GetScheduleTeamNumberFromTeamNumber(scheduleNo, Convert.ToInt32(txtVisitor.Text));
                if (game.VisitingTeamScore == null)
                    game.VisitingTeamScore = -1;
                else
                    game.VisitingTeamScore = game.VisitingTeamScore;
                if (game.HomeTeamScore == null)
                    game.HomeTeamScore = -1;
                else
                    game.HomeTeamScore = game.HomeTeamScore;
                game.DivisionId = Int32.Parse(ddlDivisions.SelectedValue);
                game.SeasonId = Master.SeasonId;

                using (var db = new CSBCDbContext())
                {
                    new ScheduleGameRepository(db).Update(game);
                    db.SaveChanges();
                }
            }
            catch (Exception e)
            {
                lblError.Text = "Update Regular Season Game:" + e.Message;
            }
        }
예제 #4
0
파일: Games1.aspx.cs 프로젝트: rsalit/CSBC
        private void UpdatePlayoffGame(int scheduleNo, int gameNo)
        {
            try
            {
                if (gameNo > 0)
                {
                    var vm = new ScheduleGamesVM();
                    var game = vm.GetPlayoffByScheduleAndGameNo(scheduleNo, gameNo);
                    if (game != null)
                    {
                        game.GameDate = ConcatDateTime(mskDate.Text, txtTime.Text);
                        game.GameTime = txtTime.Text;
                        game.LocationNumber = Convert.ToInt32(cmbVenues.SelectedItem.Value);
                        game.HomeTeam = txtHome.Text;
                        game.VisitingTeam = txtVisitor.Text;
                        game.Descr = txtDescr.Text;
                        game.DivisionId = Convert.ToInt32(ddlDivisions.SelectedValue);

                        using (var db = new CSBCDbContext())
                        {
                            var rep = new SchedulePlayoffRepository(db);
                            rep.Update(game);
                            db.SaveChanges();
                        }
                    }
                }
                else
                {
                    var date = ConcatDateTime(mskDate.Text, txtTime.Text);

                    ScheduleGamesVM.AddPlayoffGame(scheduleNo, date, txtTime.Text,
                        Convert.ToInt32(cmbVenues.SelectedItem.Value), txtHome.Text, txtVisitor.Text, txtDescr.Text,Convert.ToInt32(cmbDivisions.SelectedValue));
                }

            }
            catch (Exception e)
            {
                lblError.Text = "Update Regular Season Game:" + e.Message;
            }
        }
예제 #5
0
파일: Games1.aspx.cs 프로젝트: rsalit/CSBC
 private void AddRegularSeasonGame(int scheduleNo)
 {
     using (var db = new CSBCDbContext())
     {
         var rep = new ScheduleGameRepository(db);
         var game = new ScheduleGame();
         try
         {
             game.ScheduleNumber = scheduleNo;
             game.GameDate = (DateTime)ConcatDateTime(mskDate.Text, txtTime.Text);
             game.GameTime = txtTime.Text;
             game.HomeTeamNumber = ScheduleGamesVM.GetScheduleTeamNumberFromTeamNumber(ScheduleNo, Convert.ToInt32(txtHome.Text));
             game.VisitingTeamNumber = ScheduleGamesVM.GetScheduleTeamNumberFromTeamNumber(ScheduleNo, Convert.ToInt32(txtVisitor.Text));
             game.LocationNumber = Convert.ToInt32(cmbVenues.SelectedItem.Value);
             if (game.VisitingTeamScore == null)
                 game.VisitingTeamScore = -1;
             else
                 game.VisitingTeamScore = game.VisitingTeamScore;
             if (game.HomeTeamScore == null)
                 game.HomeTeamScore = -1;
             else
                 game.HomeTeamScore = game.HomeTeamScore;
             game.DivisionId = Int32.Parse(ddlDivisions.SelectedValue);
             game.SeasonId = Master.SeasonId;
             //_with1.Descr = txtDescr.Text;
             var newGame = rep.Insert(game);
             db.SaveChanges(); //this should be in UOM!
             GameNo = newGame.GameNumber;
         }
         catch (Exception ex)
         {
             Session["ErrorMSG"] = "ADDRow::" + ex.Message;
         }
     }
 }
예제 #6
0
파일: Games1.aspx.cs 프로젝트: rsalit/CSBC
 private void AddPlayoffGame(int scheduleNo)
 {
     using (var db = new CSBCDbContext())
     {
         var rep = new SchedulePlayoffRepository(db);
         var game = new SchedulePlayoff();
         try
         {
             game.ScheduleNumber = scheduleNo;
             game.GameDate = (DateTime)ConcatDateTime(mskDate.Text, txtTime.Text);
             game.GameTime = txtTime.Text;
             game.HomeTeam = txtHome.Text;
             game.VisitingTeam = txtVisitor.Text;
             game.LocationNumber = Convert.ToInt32(cmbVenues.SelectedItem.Value);
             game.Descr = txtDescr.Text;
             game.DivisionId = Convert.ToInt32(ddlDivisions.SelectedValue);
             var newGame = rep.Insert(game);
             db.SaveChanges(); //this should be in UOM!
             GameNo = newGame.GameNumber;
         }
         catch (Exception ex)
         {
             Session["ErrorMSG"] = "ADDRow::" + ex.Message;
         }
     }
 }
예제 #7
0
 internal static void AddPlayoffGame(int scheduleNo, DateTime? date, string gameTime, int locationNumber,
     string homeTeam, string visitorTeam, string description, int divisionId)
 {
     using (var db = new CSBCDbContext())
     {
         var rep = new SchedulePlayoffRepository(db);
         var game = new SchedulePlayoff
         {
             ScheduleNumber = scheduleNo,
             GameDate = date,
             GameTime = gameTime,
             LocationNumber = locationNumber,
             HomeTeam = homeTeam,
             VisitingTeam = visitorTeam,
             Descr = description,
             DivisionId = divisionId
         };
         rep.Insert(game);
         db.SaveChanges();
     }
 }