protected void btnAddTransferWindow_Click(object sender, EventArgs e) { //kontrollera att det inte finns fler transferfönster änvad som angetts i turneringen using (var db = Global.GetConnection()) { var transferWindows = db.Inti_TransferPeriod.Where(tf => tf.TournamentGUID == TourId); var tour = db.Inti_Tournament.Single(t => t.GUID == TourId); var transferWindow = new Inti_TransferPeriod(); transferWindow.TournamentGUID = TourId; transferWindow.StartDate = tour.StartRegistration; transferWindow.EndDate = tour.StartRegistration; transferWindow.Name = "Nytt transferfönster"; transferWindow.Description = ""; db.Inti_TransferPeriod.InsertOnSubmit(transferWindow); db.SubmitChanges(); LoadTransferWindows(); LoadTransferWindow(transferWindow.GUID); } }
public void CommitTransfers(IntiDataContext db, Inti_TransferPeriod transferPeriod, Inti_TeamVersion currentVersion, Inti_TeamVersion transferVersion, Guid teamId) { //add transfers IList<Inti_TeamTransfer> transfers = new List<Inti_TeamTransfer>(); foreach (var teamAthlete in currentVersion.Inti_TeamAthlete.ToList()) { //is this athlete removed in the new version? if (transferVersion.Inti_TeamAthlete.Where(ta => ta.AthleteGUID == teamAthlete.AthleteGUID).ToList().Count == 0) { var transfer = new Inti_TeamTransfer(); transfer.TeamGUID = teamId; transfer.TransferDate = transferPeriod.EndDate; transfer.AthleteOutGUID = teamAthlete.AthleteGUID; transfer.AthleteInGUID = Guid.Empty; transfers.Add(transfer); } } foreach (var teamAthlete in transferVersion.Inti_TeamAthlete.ToList()) { //is this athlete present in the old version? if (currentVersion.Inti_TeamAthlete.Where(ta => ta.AthleteGUID == teamAthlete.AthleteGUID).ToList().Count == 0) { foreach (var tr in transfers) { if (tr.AthleteInGUID == Guid.Empty) { tr.AthleteInGUID = teamAthlete.AthleteGUID; db.Inti_TeamTransfer.InsertOnSubmit(tr); break; } } } } //update validTo and ValidFroms transferVersion.ValidFrom = transferPeriod.EndDate; currentVersion.ValidTo = transferPeriod.EndDate.AddDays(-1); db.SubmitChanges(); LogEvent(teamId, typeof(Inti_Team), SessionProperties.UserGuid, SessionProperties.ClientInfo, EventType.Update, "Genomfört byten"); }
public void CommitTransfers(IntiDataContext db, Inti_TransferPeriod transferPeriod, Inti_TeamVersion currentVersion, Inti_TeamVersion transferVersion, Guid teamId) { //add transfers IList <Inti_TeamTransfer> transfers = new List <Inti_TeamTransfer>(); foreach (var teamAthlete in currentVersion.Inti_TeamAthlete.ToList()) { //is this athlete removed in the new version? if (transferVersion.Inti_TeamAthlete.Where(ta => ta.AthleteGUID == teamAthlete.AthleteGUID).ToList().Count == 0) { var transfer = new Inti_TeamTransfer(); transfer.TeamGUID = teamId; transfer.TransferDate = transferPeriod.EndDate; transfer.AthleteOutGUID = teamAthlete.AthleteGUID; transfer.AthleteInGUID = Guid.Empty; transfers.Add(transfer); } } foreach (var teamAthlete in transferVersion.Inti_TeamAthlete.ToList()) { //is this athlete present in the old version? if (currentVersion.Inti_TeamAthlete.Where(ta => ta.AthleteGUID == teamAthlete.AthleteGUID).ToList().Count == 0) { foreach (var tr in transfers) { if (tr.AthleteInGUID == Guid.Empty) { tr.AthleteInGUID = teamAthlete.AthleteGUID; db.Inti_TeamTransfer.InsertOnSubmit(tr); break; } } } } //update validTo and ValidFroms transferVersion.ValidFrom = transferPeriod.EndDate; currentVersion.ValidTo = transferPeriod.EndDate.AddDays(-1); db.SubmitChanges(); LogEvent(teamId, typeof(Inti_Team), SessionProperties.UserGuid, SessionProperties.ClientInfo, EventType.Update, "Genomfört byten"); }
public void ReOpenTeamForTransfers(IntiDataContext db, Inti_TransferPeriod transferPeriod, Inti_TeamVersion transferVersion, Inti_TeamVersion currentVersion, Guid teamId) { //remove transfers var transfers = db.Inti_TeamTransfer.Where( tf => tf.TeamGUID == teamId && tf.TransferDate == transferPeriod.EndDate).ToList(); if (transfers.Count > 0) { db.Inti_TeamTransfer.DeleteAllOnSubmit(transfers); } //update validTo and ValidFroms transferVersion.ValidFrom = null; currentVersion.ValidTo = null; db.SubmitChanges(); LogEvent(teamId, typeof(Inti_Team), SessionProperties.UserGuid, SessionProperties.ClientInfo, EventType.Update, "Ångrat byten"); }
public void ReOpenTeamForTransfers(IntiDataContext db, Inti_TransferPeriod transferPeriod, Inti_TeamVersion transferVersion, Inti_TeamVersion currentVersion, Guid teamId) { //remove transfers var transfers = db.Inti_TeamTransfer.Where( tf => tf.TeamGUID == teamId && tf.TransferDate == transferPeriod.EndDate).ToList(); if (transfers.Count > 0) db.Inti_TeamTransfer.DeleteAllOnSubmit(transfers); //update validTo and ValidFroms transferVersion.ValidFrom = null; currentVersion.ValidTo = null; db.SubmitChanges(); LogEvent(teamId, typeof(Inti_Team), SessionProperties.UserGuid, SessionProperties.ClientInfo, EventType.Update, "Ångrat byten"); }
private void detach_Inti_TransferPeriod(Inti_TransferPeriod entity) { this.SendPropertyChanging(); entity.Inti_Tournament = null; }
partial void DeleteInti_TransferPeriod(Inti_TransferPeriod instance);
partial void UpdateInti_TransferPeriod(Inti_TransferPeriod instance);
partial void InsertInti_TransferPeriod(Inti_TransferPeriod instance);
private void ShowTransferWindow(Inti_TransferPeriod tf, bool undoChanges) { //show info about the transfer period lblTransferPeriodInfo.Text = "Transferfönstret " + tf.Name + " är öppet från och med " + tf.StartDate.ToString() + " till " + tf.EndDate + "."; lblTransferPeriodInfo.Text += "<br>" + tf.Description; pnlFutureLineUp.Visible = false; //create new team version if needed using (var db = Global.GetConnection()) { Inti_TeamVersion transferVersion = null; Inti_TeamVersion currentVersion = null; GetCurrentAndTransferVersion(db, out currentVersion, out transferVersion); if(transferVersion.ValidFrom == null) { lblTransferPeriodInfo.Text += "<br><div class=\"redFrame\"><b>" + "Tänk på att du måste klicka på knappen \"Genomför byten\" "; lblTransferPeriodInfo.Text += "när du är färdiga med dina byten. Annars tror vi bara att du lattjat runt lite.</b></div>"; if ((undoChanges || transferVersion.Inti_TeamAthlete.ToList().Count == 0) && currentVersion != null && transferVersion != null) { var trans = new UserTeamManagement(Global.ConnectionString, SessionProps); trans.ReloadTransferVersion(db, transferVersion, currentVersion, TeamId); } //load transfer controls LoadTransferControls(transferVersion, db); pnlTeamTransfers.Visible = true; btnReOpenTransferTeam.Visible = false; } else { lblTransferPeriodInfo.Text += "<br><br><span class=\"label label-success\">Dina byten är gjorda.</span> Vill du ändra något, klicka på knappen \"Ångra genomförande av byten\""; lblTransferPeriodInfo.Text += "<br>Tänk på att du då måste klicka på knappen \"Genomför byten\" igen för att bytena ska gå igenom."; pnlTeamTransfers.Visible = false; btnReOpenTransferTeam.Visible = true; } } }