Beispiel #1
0
        protected bool SaveOption(Message message)
        {
            bool result       = false;
            var  currentState = new RefusalWorkflowStatus();

            try
            {
                currentState = GetCurrentState(message.Chat.Id);

                //get selected option
                var refusalTypes = RefusalTypeRepository.List();
                var type         = refusalTypes.Find(itm => itm.Name.ToLower().Contains(message.Text.ToLower()));

                //save feedback
                RefusalRepository.AddEdit(new Refusal()
                {
                    UserId        = currentState.UserId,
                    ProductId     = currentState.ProductId,
                    RefusalTypeId = type?.Id ?? 0
                });

                Api.SendTextMessageAsync(message.Chat.Id, TelegramBotMessages.AskRefusalSuccess);

                //update current state
                UpdateCurrentState(message.Chat.Id, RefusalWorkflowStatusType.SavedOptions);

                result = true;
            }
            catch (Exception ex)
            {
                ErrorRepository.AddEdit(new Error()
                {
                    ChatId                  = message.Chat.Id,
                    ErrorCode               = ex.HResult,
                    ErrorMessage            = ex.Message,
                    StackTrace              = ex.StackTrace,
                    RefusalWorkflowStatusId = currentState.ProcessStage
                });
            }
            return(result);
        }
Beispiel #2
0
        protected bool SaveOther(Message message)
        {
            var currentState = new RefusalWorkflowStatus();

            try
            {
                currentState = GetCurrentState(message.Chat.Id);

                //get selected option
                var refusalTypes = RefusalTypeRepository.List();
                var type         = refusalTypes.Find(itm => itm.HasComment);

                //save feedback
                RefusalRepository.AddEdit(new Refusal()
                {
                    UserId         = currentState.UserId,
                    ProductId      = currentState.ProductId,
                    RefusalTypeId  = type?.Id ?? 0,
                    RefusalComment = message.Text
                });

                Api.SendTextMessageAsync(message.Chat.Id, TelegramBotMessages.AskRefusalSuccess);
                UpdateCurrentState(message.Chat.Id, RefusalWorkflowStatusType.SavedOther);
            }
            catch (Exception ex)
            {
                ErrorRepository.AddEdit(new Error()
                {
                    ChatId                  = message.Chat.Id,
                    ErrorCode               = ex.HResult,
                    ErrorMessage            = ex.Message,
                    StackTrace              = ex.StackTrace,
                    RefusalWorkflowStatusId = currentState.ProcessStage
                });
            }

            return(true);
        }