public void ProcessSignupInviteConversation(TxtMsgInbound msgInbound, TxtMsgAwaitingResponse awaiting, AppUser user) { string mobileToInvite = PhoneUtil.CleanAndEnsureCountryCode(msgInbound.Message); if (MessageUtility.IsCancelRequested(msgInbound)) { _omm.SendFeedbackToInboundMessageAndDeleteAwaiting(msgInbound, string.Format("Ok, invitation cancelled."), user.Id, awaiting); return; } if (!PhoneUtil.IsValidPhoneNumber(mobileToInvite)) { _omm.SendFeedbackToInboundMessage(msgInbound, string.Format("'{0}' is not a valid mobile number to invite to signup for mysitterhub.com. Please enter 10 digit number. Or say 'cancel'.", msgInbound.Message), user.Id); return; } int parentId = awaiting.WaitingForUserId; AppUser parentUser = new AppUserDal().GetById(parentId); if (parentUser.UserRole != UserRole.Parent) { //STEP - make sure user is a Parent, if not say only parents can invite sitters. _omm.SendFeedbackToInboundMessage(msgInbound, MessageTemplates.OnlyParentsCanSendSignupInvites(), user.Id); } else { //STEP - confirm sending invite _omm.SendFeedbackToInboundMessage(msgInbound, "Sending invite to " + mobileToInvite, user.Id); var sitterInvite = new InviteToSignup {MobilePhone = mobileToInvite}; ServiceResult result = new ParentRepository().AddSitterInviteByMobile(parentId, sitterInvite); if (!result.IsSuccess) { _omm.SendFeedbackToInboundMessage(msgInbound, "Error while sending invite to " + mobileToInvite + " please try again.", user.Id); } } _txtMsgAwaitingResponseDal.DeleteAwaiting(awaiting.Id); }
public void ProcessPostJobCommand(TxtMsgInbound msgInbound, AppUser parentUser) { if (parentUser.UserRole != UserRole.Parent) { string msg3 = string.Format(MessageTemplates.MySitterHubPefix() + " Sorry, only parents can post jobs."); _omm.SendFeedbackToInboundMessage(msgInbound, msg3, parentUser.Id); return; } int count = new ParentRepository().GetSitterCountForParent(parentUser.Id); if (count == 0) { string msg2 = string.Format(MessageTemplates.MySitterHubPefix() + " Sorry, you can't post a job until you have added sitters. Say 'invite' to invite sitters."); _omm.SendFeedbackToInboundMessage(msgInbound, msg2, parentUser.Id); return; } string msg = string.Format("I'll post a job for you. Which day: {0}?", DaysOfWeekStartingToday(parentUser)); _omm.SendFeedbackToInboundMessageAndAwait(msgInbound, msg, parentUser.Id, InboundMessageType.PostJob_Step2_DayOfWeek); }