/// <summary> /// Deprecated Method for adding a new object to the sportseventparticipation EntitySet. Consider using the .Add method of the associated ObjectSet<T> property instead. /// </summary> public void AddTosportseventparticipation(sportseventparticipation sportseventparticipation) { base.AddObject("sportseventparticipation", sportseventparticipation); }
/// <summary> /// Create a new sportseventparticipation object. /// </summary> /// <param name="id">Initial value of the Id property.</param> /// <param name="dateCreated">Initial value of the DateCreated property.</param> /// <param name="dateUpdated">Initial value of the DateUpdated property.</param> /// <param name="dateRegistered">Initial value of the DateRegistered property.</param> public static sportseventparticipation Createsportseventparticipation(global::System.Int32 id, global::System.DateTime dateCreated, global::System.DateTime dateUpdated, global::System.DateTime dateRegistered) { sportseventparticipation sportseventparticipation = new sportseventparticipation(); sportseventparticipation.Id = id; sportseventparticipation.DateCreated = dateCreated; sportseventparticipation.DateUpdated = dateUpdated; sportseventparticipation.DateRegistered = dateRegistered; return sportseventparticipation; }
/// <summary> /// Constructor. Construct a DAL object based on a DB object. /// </summary> public SportsEventParticipationDal(sportseventparticipation sportseventparticipation) { _sportseventparticipation = sportseventparticipation; }
/// <summary> /// Constructor. Construct an empty DAL object. /// </summary> public SportsEventParticipationDal() { _sportseventparticipation = new sportseventparticipation(); }
/// <summary> /// Save an entry. /// </summary> /// <param name="inschrijving"></param> /// <param name="eventNumber"></param> public static void SaveEntry(InschrijvingModel inschrijving, string eventNumber, bool isScrape, bool overrideLocallyUpdated = false) { // TODO BW 2013-02-6 Als een inschrijving wordt gesaved die is gescraped van NTB inschrijvingen, maar het e-mail adres is // inmiddels aangepast dan werkt onderstaande niet. De persoon wordt dan onder een nieuwe inschrijving gesaved en klapt er mogelijk uit op duplicate NTB licentie nummer.. inschrijving.Email = inschrijving.Email.ToLower(); bool isEmailGewijzigd = (!string.IsNullOrEmpty(inschrijving.EmailBeforeUpdateIfAny) && inschrijving.EmailBeforeUpdateIfAny!=inschrijving.Email); string gebruikersnaam = isEmailGewijzigd ? inschrijving.EmailBeforeUpdateIfAny : inschrijving.Email; // Create and/or retrieve the user (and the underlying ASP.NET membership user). LogonUserDal user = LogonUserDal.CreateOrRetrieveUser(gebruikersnaam, "", inschrijving.ExternalIdentifier); // Update the rest of the user data ONLY if: // - It is NOT being scraped for this save // - Or the raceEntry is first created // - OR it IS being scraped but was scraped before and was NOT updated after it was last scraped (e.g. DateUpdated<=DateLastScraped) // TODO: Update (and save) only if the information is newer; somehow... if (overrideLocallyUpdated || !isScrape || !user.DateOfBirth.HasValue || (!inschrijving.DateLastSynchronized.HasValue || (inschrijving.DateLastSynchronized.HasValue && DateTime.Compare(inschrijving.DateUpdated, inschrijving.DateLastSynchronized.Value)<=0))) { user.DateOfBirth = inschrijving.GeboorteDatum; user.IsMailingListMember = inschrijving.Newsletter; if (user.EmailAddress != inschrijving.Email) { // TODO BW 2013-07-28: A check has to be added that the new e-mail address does not exist yet (or is it already present?). if (Membership.GetUser(inschrijving.Email)!=null) { throw new ArgumentException(string.Format("Het e-mail adres is gewijzigd van {0} naar {1}, maar dit laatste e-mail adres is al gebruikt door een andere gebruiker.", user.EmailAddress, inschrijving.Email)); } user.EmailAddress = inschrijving.Email; // Set user status as unconfirmed, since the e-mail address is changed, and the new address is not confirmed yet. user.Status = Business.LogonUserStatus.Undetermined; } user.UserName = inschrijving.Email; user.TelephoneNumber = inschrijving.Telefoon; user.NtbLicenseNumber = inschrijving.HasLicentieNummer ? inschrijving.LicentieNummer : null; user.IsActive = false; if (!string.IsNullOrEmpty(inschrijving.Geslacht)) { user.Gender = inschrijving.Geslacht=="M"; } // If the user has no address or the addres was updated later then the user then add an address. address address = user.PrimaryAddress; if (address==null) { throw new ArgumentException("address is null. This should not occur. This code should be able to be deleted :P."); // Create an address. // address = new address(); // address.DateCreated = DateTime.Now; } address.DateUpdated = DateTime.Now; if (address.DateCreated==null || address.DateCreated==DateTime.MinValue) { address.DateCreated = DateTime.Now; } address.City = inschrijving.Woonplaats; address.Street = inschrijving.Straat; address.Housenumber = inschrijving.Huisnummer; address.HouseNumberAddition = inschrijving.HuisnummerToevoeging; address.Country = inschrijving.Land; address.Firstname = inschrijving.Voornaam; address.Insertion = inschrijving.Tussenvoegsel; address.Lastname = inschrijving.Achternaam; address.PostalCode = inschrijving.Postcode; user.PrimaryAddress = address; user.Save(); // Set the userId of the inschrijvingmodel, if not set before (for registration of completely new users). if (inschrijving.UserId==0) { inschrijving.UserId=user.Id; } int eventId = SportsEventRepository.GetEvent(eventNumber).Id; // Create the sportsparticipation. sportseventparticipation participation = (from p in DB.sportseventparticipation where p.UserId==user.Id && p.SportsEventId == eventId select p).FirstOrDefault(); if (participation==null) { participation = new sportseventparticipation(); SportsEventDal sportsevent = SportsEventDal.GetByExternalId(eventNumber); participation.SportsEventId = sportsevent.ID; participation.EarlyBird = inschrijving.IsEarlyBird; } participation.DateUpdated = DateTime.Now; // If datecreated wasn't set (e.g. it is new) then set it identical to dateCreated. if (participation.DateCreated==DateTime.MinValue) { participation.DateCreated=participation.DateUpdated; } participation.MyLapsChipIdentifier = inschrijving.HasMyLapsChipNummer ? inschrijving.MyLapsChipNummer : string.Empty; if (isScrape) { participation.ExternalIdentifier=inschrijving.ExternalIdentifier; if (!participation.DateFirstScraped.HasValue) { participation.DateFirstScraped = participation.DateUpdated; } participation.DateLastScraped = participation.DateUpdated; participation.DateRegistered=inschrijving.RegistrationDate; } else { participation.ExternalIdentifier = inschrijving.ExternalIdentifier; participation.DateRegistered = participation.DateUpdated; participation.ParticipationAmountInEuroCents = inschrijving.InschrijfGeld; } // Initialiseer de virtuele datum voor orderen op de inschrijfdatum (door wijzigen kun je later de volgorde 'kunstmatig' wijzigen, maar dit is wel iets minder kunstmatig dan met de inschrijfdatum zelf :P). if (!participation.VirtualRegistrationDateForOrdering.HasValue) { participation.VirtualRegistrationDateForOrdering = participation.DateRegistered; } participation.SportsEventId = (from sportsevent se in DB.sportsevent where se.ExternalEventIdentifier==eventNumber select se.Id).First(); participation.UserId = user.Id; participation.SpeakerRemarks = inschrijving.OpmerkingenTbvSpeaker; participation.Camp = inschrijving.Camp; participation.Food = inschrijving.Food; participation.Bike = inschrijving.Bike; participation.WantsToDoFinal = inschrijving.Finale=="W"; participation.TShirtSize = inschrijving.MaatTshirt; participation.ParticipationStatus = 1; participation.Notes = inschrijving.OpmerkingenAanOrganisatie; participation.NotesToAll = inschrijving.HebJeErZinIn; participation.DateConfirmationSend = inschrijving.DateConfirmationSend; participation.BankCode = inschrijving.BankCode; participation.PaymentType = (int?) inschrijving.Betaalwijze; if (participation.Id==0) { DB.AddTosportseventparticipation(participation); } DB.SaveChanges(); inschrijving.ParticipationId = participation.Id; inschrijving.RegistrationDate = participation.DateRegistered; } }