public Driver GetDriverByEmailAddress(string emailAddress) { var driver = new Driver(); using (var connection = new EntityConnection("name=CoreContainer")) { _core = new CoreContainer(connection); driver = _core.Drivers .Include("HomeClub") .Where(d => d.EmailAddress == emailAddress) .FirstOrDefault(); } return driver; }
public DriverViewModel RegisterNewDriver(DriverViewModel driverModel) { var newDriver = new Driver { FirstName = driverModel.FirstName, LastName = driverModel.LastName ?? string.Empty, RccScreenName = driverModel.ScreenName ?? string.Empty, City = driverModel.City ?? string.Empty, State = !driverModel.State.Equals("-1") ? driverModel.State : string.Empty, EmailAddress = driverModel.EmailAddress ?? string.Empty, DateActivated = DateTime.Today, DateCreated = DateTime.Now }; if (driverModel.HomeClubId > 0) { newDriver.HomeClubId = driverModel.HomeClubId; } try { //Membership.CreateUser(newDriver.EmailAddress, driverModel.Password, newDriver.EmailAddress); _driverRepository.SaveNewDriver(newDriver); // if(driverModel.HomeClubId == -2) // { // driverModel.StatusMessage = MvcHtmlString.Create("<p>" + // "Thank you for registering as Driver on ProgressTen.com. Since your club is not yet a ProgressTen " + // "subscribing club, you will be able to view other clubs pages as a guest and are able to be included " + // "in events with any ProgressTen club that you may visit." + // "</p>" + // "<p>" + // "Once your club is subscribed with ProgressTen.com, you will be able to connect yourself to that club " + // "by editing your profile and selecting your club."); // } // else // { driverModel.StatusMessage = MvcHtmlString.Create("<p>" + "The new driver, " + newDriver.FullDisplayName + ", has been added.</p>" + "<p>Return To Scores Page</p>" + "<p>Return To Dirvers List</p>"); // using (var _mailClient = new SmtpClient(ConfigurationManager.AppSettings["SmtpServer"])) // { // var message = new MailMessage(); // var homeClub = _clubService.GetClubById(newDriver.HomeClubId.GetValueOrDefault(0)); // string toAddress = homeClub.CurrentPresident.EmailAddress; // message.To.Add(new MailAddress(toAddress)); // message.From = new MailAddress("*****@*****.**", "ProgressTen Registration"); // message.Subject = "ProgressTen - New Driver Registration"; // message.Body = @" //A new driver has registered with ProgressTen.com and has selected " + homeClub.Acronym + @" as thier home club:\n\n //Driver Name: " + newDriver.FullName + @"\n //ScreenName: " + newDriver.RccScreenName + @"\n //City: " + newDriver.City + @"\n //State: " + newDriver.State + @"\n //Email: " + newDriver.EmailAddress + @"\n // //Yourself or any designated ProgressTen.com club admin can approve or decline this new driver on the Drivers tab in your club's area. // //Thanks //ProgressTen.com"; // _mailClient.Send(message); // } // } } catch (Exception ex) { log.Error("Problem Creating New Driver", ex); driverModel.StatusMessage = MvcHtmlString.Create("<p>" + "There was a problem submitting this new driver. 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 driverModel; }
public Driver SaveNewDriver(Driver driver) { using (var connection = new EntityConnection("name=CoreContainer")) { _core = new CoreContainer(connection); _core.Drivers.AddObject(driver); _core.SaveChanges(); } return driver; }
public Driver UpdateDriver(Driver driver) { using (var connection = new EntityConnection("name=CoreContainer")) { _core = new CoreContainer(connection); _core.Drivers.Attach(_core.Drivers.Single(c => c.DriverId == driver.DriverId)); _core.Drivers.ApplyCurrentValues(driver); _core.SaveChanges(); } return driver; }
public Driver GetDriverByScreenName(string screenName) { var driver = new Driver(); using (var connection = new EntityConnection("name=CoreContainer")) { _core = new CoreContainer(connection); driver = _core.Drivers.Where(d => d.RccScreenName == screenName).FirstOrDefault(); } return driver; }
public Driver GetDriverById(int driverId) { var driver = new Driver(); using (var connection = new EntityConnection("name=CoreContainer")) { _core = new CoreContainer(connection); driver = _core.Drivers.Where(d => d.DriverId == driverId).FirstOrDefault(); } return driver; }
/// <summary> /// Deprecated Method for adding a new object to the Drivers EntitySet. Consider using the .Add method of the associated ObjectSet<T> property instead. /// </summary> public void AddToDrivers(Driver driver) { base.AddObject("Drivers", driver); }
/// <summary> /// Create a new Driver object. /// </summary> /// <param name="driverId">Initial value of the DriverId property.</param> /// <param name="firstName">Initial value of the FirstName property.</param> /// <param name="lastName">Initial value of the LastName property.</param> /// <param name="emailAddress">Initial value of the EmailAddress property.</param> /// <param name="dateCreated">Initial value of the DateCreated property.</param> public static Driver CreateDriver(global::System.Int32 driverId, global::System.String firstName, global::System.String lastName, global::System.String emailAddress, global::System.DateTime dateCreated) { Driver driver = new Driver(); driver.DriverId = driverId; driver.FirstName = firstName; driver.LastName = lastName; driver.EmailAddress = emailAddress; driver.DateCreated = dateCreated; return driver; }
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; }