public SignupResult SaveNewSignup(SignupInfo signupInfo,bool requireValidEmail = true, bool requireSitterParentPhone = false) { var result = new SignupResult() ; ValidateSignup(signupInfo, result, requireValidEmail, requireSitterParentPhone); if (result.Error != null) return result; signupInfo.User.Email = signupInfo.User.Email.ToLower(); _appUserDal.InsertUser(signupInfo.User); var userPass = new AppUserPass { Id = signupInfo.User.Id, PasswordHash = StringHasher.GetHashString(signupInfo.Pass), Token = Guid.NewGuid().ToString(), Email = signupInfo.User.Email.ToLower(), MobilePhone = signupInfo.User.MobilePhone }; _userPassDal.InsertUserPass(userPass); if (signupInfo.User.UserRole == UserRole.Parent) { var parent = new Parent {Id = signupInfo.User.Id}; _parentDal.Insert(parent); } else if (signupInfo.User.UserRole == UserRole.Sitter) { var sitter = new Sitter { Id = signupInfo.User.Id, ParentEmail = signupInfo.SitterSignupInfo.ParentEmail, ParentMobile = signupInfo.SitterSignupInfo.ParentMobile, Age = signupInfo.SitterSignupInfo.Age }; _sitterDal.Insert(sitter); result.NewId = sitter.Id; } else if (signupInfo.User.UserRole == UserRole.Admin) { } else { throw new AppException(string.Format("userRole '{0}' not valid", signupInfo.User.UserRole)); } string userName = signupInfo.User.Email.ToLower() != null ? signupInfo.User.Email.ToLower() : signupInfo.User.MobilePhone; result.newUserData =_authDal.AuthenticateUserByName(userName); result.IsSuccess = true; return result; }
private void AddSitterToParentMySitters(int sitterId, Parent parent, string sitterMobilePhone) { var newS = new ParentMySitter {SitterId = sitterId, Rate = LogicConstants.DefaultSitterRate, SortOrder = 99}; _parentRepository.AddSitter(parent.Id, newS); _parentRepository.CancelInviteSitter(parent.Id, sitterMobilePhone); }
/* * We send it to sitter that replies 'yes' on parent's sitterhub invitation. */ public static string FormatUserAddedToSitters(Parent parent) { return string.Format("Sweet! {0} can now invite you to babysit.", (parent == null || parent.User == null ? "parent" : parent.User.FirstNameLastInitial())); }
/* * We send it to sitter that replies 'no' on parent's sitterhub invitation. */ public static string FormatDeclineInvitationToSitterhub(Parent parent) { return string.Format("OK, we'll let {0} know you have declined the job.", (parent == null || parent.User == null ? "parent" : parent.User.FirstNameLastInitial())); }
/* * We send it to sitter that replies 'yes' on parent's sitterhub invitation and new account was created for him. */ public static string FormatUserAddedToSittersAndProfileCreated(Parent parent, string password) { string sweet = FormatUserAddedToSitters(parent); return sweet + string.Format(" An account has been set up for you. Your temporary password is {1}. Go to mysitterhub.com/profile to complete your profile.", (parent == null || parent.User == null ? "parent" : parent.User.FirstNameLastInitial()), password); }
public static string FormatOkAddedToParentMySitters(Parent parent, bool isAdded) { return string.Format("OK, you have {0} been added to {1}'s sitters.", isAdded ? "" : "not", (parent == null || parent.User == null ? "parent" : parent.User.FirstNameLastInitial())); }
public void Update(Parent parent) { MongoCnn.GetParentCollection().Save(parent); }
public void Insert(Parent parent) { MongoCnn.GetParentCollection().Insert(parent); }
/// <summary> /// Does not update User property of parent (just list of sitters) /// </summary> public bool UpdateParent(Parent p) { _parentDal.Update(p); return true; }