public static BasicResponse resetUserPasswordEmailImplementation(ResetPasswordEmailRequest request)
        {
            if (String.IsNullOrWhiteSpace(request.email))
            {
                return(new BasicResponse {
                    message = "Please enter an email.", status = 601, success = false
                });
            }

            using (var db = new UniversalGymEntities())
            {
                var user = db.Users.SingleOrDefault(f => f.Email == request.email);
                if (user == null)
                {
                    return(new BasicResponse {
                        message = "User not found.", status = 404, success = false
                    });
                }

                var forgotPasswordBody = String.Format("Someone forgot a password :/ -- {0}", request.email);
                EmailNoTemplateHelper.SendEmail("User forgot password", "*****@*****.**", forgotPasswordBody);

                user.CurrentToken = Guid.NewGuid().ToString();
                db.SaveChanges();

                var link = Constants.PedalWebUrl + "user.html#/resetPassword/" + user.UserId + "/" + user.CurrentToken;;
                EmailTemplateHelper.SendEmail("Reset Password Link - Pedal", request.email, link, user.FirstName, "reset_password.html");

                return(new BasicResponse {
                    message = "User email sent successfully", status = 3, success = true
                });
            }
        }
Example #2
0
        public static BasicResponse contactFormImplementation(ContactFormRequest request)
        {
            if (String.IsNullOrWhiteSpace(request.email))
            {
                return(new BasicResponse {
                    message = "Please enter an email", status = 200, success = false
                });
            }
            else if (String.IsNullOrWhiteSpace(request.name))
            {
                return(new BasicResponse {
                    message = "Please enter a name", status = 200, success = false
                });
            }
            else if (String.IsNullOrWhiteSpace(request.message))
            {
                return(new BasicResponse {
                    message = "Please enter a message.", status = 200, success = false
                });
            }

            var contactFormBody = "Name: "
                                  + request.name
                                  + Environment.NewLine
                                  + "Email: "
                                  + request.email
                                  + Environment.NewLine
                                  + "Message: "
                                  + request.message;

            SlackHelper.sendSupportChannel(contactFormBody);

            EmailNoTemplateHelper.SendEmail("Pedal Contact", "*****@*****.**", contactFormBody);
            EmailTemplateHelper.SendEmail("Pedal Contact", request.email, Constants.PedalWebUrl, request.name, "contact_form.html", request.message);

            return(new BasicResponse {
                message = "Success", status = 200, success = true
            });
        }
Example #3
0
        public static GymDataResponse gymRegisterImplementation(RegisterGymRequest request)
        {
            if (String.IsNullOrWhiteSpace(request.gymName))
            {
                return(new GymDataResponse {
                    success = false, status = 200, message = "Please enter a gym name"
                });
            }
            else if (String.IsNullOrWhiteSpace(request.gymPhone))
            {
                return(new GymDataResponse {
                    success = false, status = 200, message = "Please enter a gym phone number"
                });
            }

            else if (String.IsNullOrWhiteSpace(request.contactName))
            {
                return(new GymDataResponse {
                    success = false, status = 200, message = "Please enter a contact name"
                });
            }
            else if (String.IsNullOrWhiteSpace(request.contactEmail))
            {
                return(new GymDataResponse {
                    success = false, status = 200, message = "Please enter an email"
                });
            }
            else if (String.IsNullOrWhiteSpace(request.contactPhone))
            {
                return(new GymDataResponse {
                    success = false, status = 200, message = "Please enter a phone number"
                });
            }
            else if (String.IsNullOrWhiteSpace(request.website))
            {
                return(new GymDataResponse {
                    success = false, status = 200, message = "Please enter a website"
                });
            }
            else if (String.IsNullOrWhiteSpace(request.address))
            {
                return(new GymDataResponse {
                    success = false, status = 200, message = "Please enter a street"
                });
            }
            else if (String.IsNullOrWhiteSpace(request.city))
            {
                return(new GymDataResponse {
                    success = false, status = 200, message = "Please enter a city"
                });
            }
            else if (String.IsNullOrWhiteSpace(request.state))
            {
                return(new GymDataResponse {
                    success = false, status = 200, message = "Please enter a state or province"
                });
            }
            else if (String.IsNullOrWhiteSpace(request.zip))
            {
                return(new GymDataResponse {
                    success = false, status = 200, message = "Please enter a zip code"
                });
            }
            else if (String.IsNullOrWhiteSpace(request.priceTier))
            {
                return(new GymDataResponse {
                    success = false, status = 200, message = "Please select one given of the price tiers"
                });
            }
            else if (String.IsNullOrWhiteSpace(request.password) || request.password.Length < 6)
            {
                return(new GymDataResponse {
                    success = false, status = 200, message = "Please enter a password greater than 5 characters"
                });
            }
            else if (String.IsNullOrWhiteSpace(request.website))
            {
                return(new GymDataResponse {
                    success = false, status = 200, message = "Please enter a website"
                });
            }
            if (MembershipHelper.emailAlreadyExists(request.contactEmail, Constants.GymRole))
            {
                return(new GymDataResponse {
                    success = false, status = 10, message = "Email already taken."
                });
            }


            var newGymGuid = MembershipHelper.createMembership(request.contactEmail, request.password, Constants.GymRole);

            using (var db = new UniversalGymEntities())
            {
                var state = db.TypeStates.FirstOrDefault(f => f.StateAbbreviation.ToLower() == request.state.ToLower()) ??
                            db.TypeStates.First(f => f.StateAbbreviation == "00");

                var address = new Data.Address()
                {
                    StreetLine1 = request.address,
                    City        = request.city,
                    Zip         = request.zip,
                    TypeStateId = state.TypeStateId
                };
                db.Addresses.Add(address);
                var publicContactInfo = new Data.ContactInfo
                {
                    AddressId = address.AddressId,
                    Phone     = request.gymPhone,
                };
                db.ContactInfoes.Add(publicContactInfo);
                db.SaveChanges();
                var ownerContactInfo = new Data.ContactInfo
                {
                    Email = request.contactEmail,
                    Phone = request.contactPhone,
                };
                db.ContactInfoes.Add(ownerContactInfo);
                db.SaveChanges();

                var gym = new Data.Gym
                {
                    CreditDollarValue = Constants.returnGymPay(request.priceTier),
                    PriceToCharge     = Constants.returnGymPrice(request.priceTier),
                    GymName           = request.gymName,
                    IsApproved        = false,
                    OwnerName         = request.contactName,
                    Url = request.website.Contains("://") ? request.website : "http://" + request.website,
                    PublicContactInfoId = publicContactInfo.ContactInfoId,
                    OwnerContactInfoId  = ownerContactInfo.ContactInfoId,
                    GymInfo             = "",
                    GymGuid             = newGymGuid,
                    ApplicationDate     = DateTime.UtcNow,
                    IsActive            = true,
                };


                db.Gyms.Add(gym);
                var target   = request.address + " " + request.state + " " + request.zip;
                var geocoded = Geocoder.GeoCodeAddress(target);
                if (geocoded != null)
                {
                    gym.Position = System.Data.Entity.Spatial.DbGeography.FromText(geocoded.GetPointString());
                    db.SaveChanges();

                    var newgymBody = "Gym Registration"
                                     + Environment.NewLine
                                     + "Gym Name: "
                                     + gym.GymName
                                     + Environment.NewLine
                                     + "Location: "
                                     + request.address
                                     + Environment.NewLine
                                     + "City: "
                                     + request.city
                                     + Environment.NewLine
                                     + "State: "
                                     + request.state
                                     + Environment.NewLine
                                     + "Zip Code: "
                                     + request.zip
                                     + Environment.NewLine
                                     + "Gym Phone"
                                     + request.gymPhone
                                     + Environment.NewLine
                                     + "Contact Name: "
                                     + request.contactName
                                     + Environment.NewLine
                                     + "Contact Email: "
                                     + request.contactEmail
                                     + Environment.NewLine
                                     + "Contact Phone: "
                                     + request.contactPhone
                                     + Environment.NewLine
                                     + "Website: "
                                     + gym.Url
                                     + Environment.NewLine;

                    SlackHelper.sendGymSignupChannel(newgymBody, geocoded.Latitude.ToString(), geocoded.Longitude.ToString());
                    // add gym id
                    var gymId = gym.GymId;
                    var link  = Constants.PedalWebUrl + "gym.html#/login";

                    EmailTemplateHelper.SendEmail("Welcome to Pedal!", request.contactEmail, link, request.gymName, "gym_signup.html");
                }
                else
                {
                    db.ContactInfoes.Remove(gym.ContactInfo);
                    db.ContactInfoes.Remove(gym.ContactInfo1);

                    var supportText = "Gym Registration - Location not found!"
                                      + Environment.NewLine
                                      + "Gym Name: "
                                      + gym.GymName
                                      + Environment.NewLine
                                      + "Location: "
                                      + request.address
                                      + Environment.NewLine
                                      + "City: "
                                      + request.city
                                      + Environment.NewLine
                                      + "State: "
                                      + request.state
                                      + Environment.NewLine
                                      + "Zip Code: "
                                      + request.zip
                                      + Environment.NewLine
                                      + "Gym Phone"
                                      + request.gymPhone
                                      + Environment.NewLine
                                      + "Contact Name: "
                                      + request.contactName
                                      + Environment.NewLine
                                      + "Contact Email: "
                                      + request.contactEmail
                                      + Environment.NewLine
                                      + "Contact Phone: "
                                      + request.contactPhone
                                      + Environment.NewLine
                                      + "Website: "
                                      + gym.Url
                                      + Environment.NewLine;

                    SlackHelper.sendSupportChannel(supportText);

                    EmailNoTemplateHelper.SendEmail("Gym Registration Problem", "*****@*****.**", supportText);

                    return(new GymDataResponse {
                        success = false, status = 200, message = "Location could not be found. The Pedal team has been notified to look into this."
                    });
                }


                return(gymDataHelper.CreateGymDataResponse(gym.GymId, true));
            }
        }
Example #4
0
        public static BasicResponse airbnbRegisterImplementation(AirbnbRegisterRequest request)
        {
            if (String.IsNullOrWhiteSpace(request.email))
            {
                return(new BasicResponse
                {
                    message = "Please enter an email.",
                    status = 404,
                    success = false,
                });
            }

            if (String.IsNullOrWhiteSpace(request.firstName))
            {
                return(new BasicResponse
                {
                    message = "Please enter a first name.",
                    status = 404,
                    success = false,
                });
            }

            if (String.IsNullOrWhiteSpace(request.lastName))
            {
                return(new BasicResponse
                {
                    message = "Please enter a last name.",
                    status = 404,
                    success = false,
                });
            }


            if (MembershipHelper.emailAlreadyExists(request.email, Constants.UserRole))
            {
                return(new BasicResponse {
                    message = "Email is already taken", status = 10, success = false
                });
            }
            else if (String.IsNullOrWhiteSpace(request.password) || request.password.Length < 6)
            {
                return(new BasicResponse {
                    message = "Please enter a password at least 6 characters long", status = 10, success = false
                });
            }



            if (!request.password.Equals(request.confirmPassword))
            {
                return(new BasicResponse
                {
                    message = "Passwords do not match",
                    status = 404,
                    success = false,
                });
            }

            var newUserGuid = MembershipHelper.createMembership(request.email, request.password, Constants.UserRole);
            var userId      = 0;

            using (var db = new UniversalGymEntities())
            {
                var newCode = UserCode.GenerateDistinctCode(db);
                var user    = new User
                {
                    FirstName             = request.firstName,
                    LastName              = request.lastName,
                    ReferalUrl            = newCode,
                    UserGuid              = newUserGuid,
                    Email                 = request.email.ToLower(),
                    hasActiveSubscription = true,
                    hasCreditCard         = false,
                    joinDate              = DateTime.Now,
                    Credits               = 0,
                };
                db.Users.Add(user);
                db.SaveChanges();
                userId = user.UserId;



                var newuserbody = "User Signup"
                                  + Environment.NewLine
                                  + "Email: "
                                  + user.Email
                                  + Environment.NewLine
                                  + "Name: "
                                  + user.FirstName
                                  + user.LastName
                                  + Environment.NewLine
                                  + "Airbnb Host: https://www.airbnb.com/users/show/"
                                  + request.airbnbHostId;



                SlackHelper.sendUserSignupChannel(newuserbody);
            }

            EmailTemplateHelper.SendEmail("Welcome to Pedal", request.email, "http://pedal.com", request.firstName, "user_signup.html");

            return(new BasicResponse
            {
                message = "Account created! Just download the Pedal Fitness app and login!",
                status = 200,
                success = true,
            });
        }
Example #5
0
        public static AllDataResponse appSignUpImplementation(AppSignUpRequest request)
        {
            if (String.IsNullOrWhiteSpace(request.email))
            {
                return(new AllDataResponse
                {
                    message = "Please enter an email.",
                    status = 404,
                    success = false,
                });
            }

            if (String.IsNullOrWhiteSpace(request.firstName))
            {
                return(new AllDataResponse
                {
                    message = "Please enter a first name.",
                    status = 404,
                    success = false,
                });
            }

            if (String.IsNullOrWhiteSpace(request.lastName))
            {
                return(new AllDataResponse
                {
                    message = "Please enter a last name.",
                    status = 404,
                    success = false,
                });
            }



            if (MembershipHelper.emailAlreadyExists(request.email, Constants.UserRole))
            {
                return(new AllDataResponse {
                    message = "Email is already taken", status = 10, success = false
                });
            }
            else if (String.IsNullOrWhiteSpace(request.password) || request.password.Length < 6)
            {
                return(new AllDataResponse {
                    message = "Please enter a password at least 6 characters long", status = 10, success = false
                });
            }

            var newUserGuid = MembershipHelper.createMembership(request.email, request.password, Constants.UserRole);
            var userId      = 0;

            using (var db = new UniversalGymEntities())
            {
                var newCode = UserCode.GenerateDistinctCode(db);
                var user    = new User
                {
                    FirstName             = request.firstName,
                    LastName              = request.lastName,
                    ReferalUrl            = newCode,
                    UserGuid              = newUserGuid,
                    Email                 = request.email.ToLower(),
                    hasActiveSubscription = false,
                    hasCreditCard         = false,
                    joinDate              = DateTime.Now,
                    Credits               = 0,
                };
                db.Users.Add(user);
                db.SaveChanges();
                userId = user.UserId;



                var newuserbody = "User Signup"
                                  + Environment.NewLine
                                  + "Email: "
                                  + user.Email
                                  + Environment.NewLine
                                  + "Name: "
                                  + user.FirstName
                                  + user.LastName;

                SlackHelper.sendUserSignupChannel(newuserbody);
            }

            EmailTemplateHelper.SendEmail("Welcome to Pedal", request.email, "http://pedal.com", request.firstName, "user_signup.html");

            return(allDataHelper.CreateAllDataResponse(userId, true));
        }