コード例 #1
0
        public Club GetClubById(int clubId)
        {
            var club = new Club();

            using (var connection = new EntityConnection("name=CoreContainer"))
            {
                _core = new CoreContainer(connection);

                club = _core.Clubs
                        .Include("CurrentPresident")
                        .Include("Locations")
                        .Include("RegisteringDriver")
                        .Where(c => c.ClubId == clubId)
                        .FirstOrDefault();
            }

            return club;
        }
コード例 #2
0
        public Club UpdateClub(Club club)
        {
            using (var connection = new EntityConnection("name=CoreContainer"))
            {
                _core = new CoreContainer(connection);

                _core.Clubs.Attach(_core.Clubs.Single(c => c.ClubId == club.ClubId));

                _core.Clubs.ApplyCurrentValues(club);

                _core.SaveChanges();
            }

            return club;
        }
コード例 #3
0
        public Club SaveNewClub(Club club)
        {
            using (var connection = new EntityConnection("name=CoreContainer"))
            {
                _core = new CoreContainer(connection);

                _core.Clubs.AddObject(club);
                _core.SaveChanges();
            }

            return club;
        }
コード例 #4
0
 /// <summary>
 /// Create a new Club object.
 /// </summary>
 /// <param name="clubId">Initial value of the ClubId property.</param>
 /// <param name="fullName">Initial value of the FullName property.</param>
 /// <param name="acronym">Initial value of the Acronym property.</param>
 /// <param name="city">Initial value of the City property.</param>
 /// <param name="state">Initial value of the State property.</param>
 /// <param name="regionId">Initial value of the RegionId property.</param>
 /// <param name="dateCreated">Initial value of the DateCreated property.</param>
 /// <param name="country">Initial value of the Country property.</param>
 public static Club CreateClub(global::System.Int32 clubId, global::System.String fullName, global::System.String acronym, global::System.String city, global::System.String state, global::System.Int32 regionId, global::System.DateTime dateCreated, global::System.String country)
 {
     Club club = new Club();
     club.ClubId = clubId;
     club.FullName = fullName;
     club.Acronym = acronym;
     club.City = city;
     club.State = state;
     club.RegionId = regionId;
     club.DateCreated = dateCreated;
     club.Country = country;
     return club;
 }
コード例 #5
0
 /// <summary>
 /// Deprecated Method for adding a new object to the Clubs EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToClubs(Club club)
 {
     base.AddObject("Clubs", club);
 }
コード例 #6
0
        public RegisterClubViewModel RegisterNewClub(RegisterClubViewModel clubModel)
        {
            var newClub = new Club
                                {
                                    FullName = clubModel.FullName,
                                    Acronym = clubModel.Acronym,
                                    City = clubModel.City,
                                    State = clubModel.State,
                                    RegionId = clubModel.RegionId,
                                    Country = clubModel.Country,
                                    DateCreated = DateTime.Now
                                };

            var newDriver = new Driver
                                {
                                    FirstName = clubModel.FirstName,
                                    LastName = clubModel.LastName,
                                    RccScreenName = clubModel.ScreenName,
                                    City = clubModel.City,
                                    State = clubModel.State,
                                    EmailAddress = clubModel.EmailAddress.ToLower(),
                                    DateCreated = DateTime.Now
                                };

            try
            {
                Membership.CreateUser(newDriver.EmailAddress, clubModel.Password, newDriver.EmailAddress);

                _driverRepository.SaveNewDriver(newDriver);
                _clubRepository.SaveNewClub(newClub);

                newClub.CurrentPresidentDriverId = newDriver.DriverId;
                newClub.RegisteringDriverId = newDriver.DriverId;

                _clubRepository.UpdateClub(newClub);

                newDriver.HomeClubId = newClub.ClubId;

                _driverRepository.UpdateDriver(newDriver);

                //clubModel.ClubId = newClub.ClubId;

                using (var _mailClient = new SmtpClient(ConfigurationManager.AppSettings["SmtpServer"]))
                {
                    var message = new MailMessage();

                    string toAddress = ConfigurationManager.AppSettings["NewClubToAddress"];

                    message.To.Add(new MailAddress(toAddress, "ProgressTen.com Registration"));
                    message.From = new MailAddress("*****@*****.**", "ProgressTen Registration");
                    message.Subject = "ProgressTen - New Club Registration";
                    message.Body = @"
            A new club has been submitted for consideration with the following information:\n\n
            Club Name: " + newClub.FullName + @"\n
            Acronym: " + newClub.Acronym + @"\n
            City: " + newClub.City + @"\n
            State: " + newClub.State + @"\n
            RegionId: " + newClub.RegionId + @"\n
            Country: " + newClub.Country + @"\n
            President's Name: " + newDriver.FullName + @"\n
            President's ScreenName: " + newDriver.RccScreenName + @"\n
            President's Email: " + newDriver.EmailAddress + @"\n";

                    _mailClient.Send(message);
                }

                clubModel.StatusMessage = MvcHtmlString.Create("<p>" +
                                            "Thank you for submitting your club as a member club of ProgressTen.com. As you know, clubs must be " +
                                            "sanctioned, or in the process of becoming sanctioned with the USRCCA. As soon as we are able to " +
                                            "confirm your status with the USRCCA, we'll notify you of your club's confirmation." +
                                            "</p>" +
                                            "<p>" +
                                            "In the mean time, you are now registered as a Driver in ProgressTen.com and you have access to the " +
                                            "public areas that are available to all Drivers who are not yet affiliated with a club. You can log in " +
                                            "anytime with the email address and password you provided." +
                                            "</p>" +
                                            "<p>" +
                                            "<a href='./" + newClub.ClubId + "' >Go To Club Page</a></p>" +
                                            "<p>" +
                                            "<a href='../Login' >Log In</a></p>");
            }
            catch (Exception ex)
            {
                log.Error("Problem Creating New Club for User:"******" Club: " + newClub.FullName, ex);

                Membership.DeleteUser(newDriver.EmailAddress);

                clubModel.StatusMessage = MvcHtmlString.Create("<p>" +
                                            "There was a problem submitting this New Club entry. You may double check that all your data was " +
                                            "entered correctly and try again. ProgressTen.com administrators have been made aware of the " +
                                            "error and will look into the matter further." +
                                            "</p>");
            }

            return clubModel;
        }