public void Observe(IUnitOfWork uow, IMessageBusiness messageBusiness, ObserverMessage msg, User user)
 {
     messageBusiness.Insert(new Message
     {
         Content        = msg.BotContent.Replace("NAME", user.FullName),
         State          = StateType.Begin,
         Type           = MessagingType.Email,
         ExtraData      = msg.Subject,
         ReplyMessageId = msg.MessageId,
         Receiver       = "*****@*****.**"// "*****@*****.**",
     });
 }
Exemple #2
0
 public void Observe(IUnitOfWork uow, IMessageBusiness messageBusiness, ObserverMessage msg, User user)
 {
     messageBusiness.Insert(new Message
     {
         Content        = msg.BotContent.Replace("NAME", user.FullName),
         Receiver       = GlobalVariable.AdminInstanceId,
         State          = StateType.Begin,
         Type           = MessagingType.RoboTele,
         ExtraData      = msg.Key,
         ReplyMessageId = msg.MessageId
     });
 }
        public void Observe(IUnitOfWork uow, IMessageBusiness messageBusiness, ObserverMessage msg, User user)
        {
            if (user.MobileNumber == 0)
            {
                return;
            }

            messageBusiness.Insert(new Message
            {
                Content  = msg.SmsContent.Replace("NAME", user.FullName),
                Receiver = user.MobileNumber.ToString(),
                State    = StateType.Begin,
                Type     = MessagingType.Sms,
            });
        }
Exemple #4
0
        public virtual JsonResult SendAddressTo(string fullAddress)
        {
            var response    = new ActionResponse <bool>();
            var currentUser = _userBusiness.Find((User as ICurrentUserPrincipal).UserId);
            var message     = new Message
            {
                Type     = MessagingType.Sms,
                Content  = string.Format(LocalMessage.SendCompanyAddressToUser, currentUser.FullName, fullAddress),
                Receiver = currentUser.MobileNumber.ToString()
            };

            var result = _messageBusiness.Insert(message);

            response.IsSuccessful = response.Result = result.IsSuccessful;
            response.Message      = result.Message;

            return(Json(response, JsonRequestBehavior.AllowGet));
        }
Exemple #5
0
        public virtual JsonResult Submit(SendMessageModel model)
        {
            var response         = new ActionResponse <bool>();
            var validMessageType = new[] { MessagingType.Email, MessagingType.Sms };

            if (!ModelState.IsValid)
            {
                response.Message = LocalMessage.InvalidFormData;
            }
            else if (!validMessageType.Contains(model.MessagingType))
            {
                response.Message = LocalMessage.InvalidEmailAddress;
                return(Json(response, JsonRequestBehavior.AllowGet));
            }
            else if ((model.MessagingType == MessagingType.Sms).And(!CellPhoneNumberValidator.IsCellPhoneNumber(model.Reciver)))
            {
                response.Message = LocalMessage.InvalidMobileNumber;
                return(Json(response, JsonRequestBehavior.AllowGet));
            }
            else if ((model.MessagingType == MessagingType.Email).And(!EmailValidator.IsEmail(model.Reciver)))
            {
                response.Message = LocalMessage.InvalidEmailAddress;
                return(Json(response, JsonRequestBehavior.AllowGet));
            }
            else
            {
                var result = _messageBusiness.Insert(new Message
                {
                    Content  = model.Message,
                    Receiver = model.Reciver,
                    Type     = model.MessagingType
                });
                response.IsSuccessful = response.Result = result.IsSuccessful;
                response.Message      = result.Message;
            }
            return(Json(response, JsonRequestBehavior.AllowGet));
        }
        public virtual JsonResult SendToMobile(int id, long mobile)
        {
            var response = new ActionResponse <bool>();

            if (!CellPhoneNumberValidator.IsCellPhoneNumber(mobile.ToString()))
            {
                return(Json(new ActionResponse <bool> {
                    Message = LocalMessage.InvalidMobileNumber
                }, JsonRequestBehavior.AllowGet));
            }

            var findedCode = _discountBusiness.Get(id);

            if (!findedCode.IsSuccessful)
            {
                return(Json(new ActionResponse <bool> {
                    Message = findedCode.Message
                }, JsonRequestBehavior.AllowGet));
            }

            var addToMessage = _messageBusiness.Insert(new Message {
                Receiver = mobile.ToString(), Type = MessagingType.Sms, Content = string.Format(LocalMessage.SendMessageDescription, findedCode.Result.Code)
            });

            if (!addToMessage.IsSuccessful)
            {
                return(Json(new ActionResponse <bool> {
                    Message = addToMessage.Message
                }, JsonRequestBehavior.AllowGet));
            }
            else
            {
                return(Json(new ActionResponse <bool> {
                    IsSuccessful = true, Message = addToMessage.Message
                }, JsonRequestBehavior.AllowGet));
            }
        }