public static void Insert(Color entity) { using (var db = new CSBCDbContext()) { var rep = new ColorRepository(db); rep.Insert(entity); db.SaveChanges(); } }
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(); }
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; } }
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; } }
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; } } }
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; } } }
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(); } }