Exemple #1
0
        public HttpResponseMessage Create(HttpRequestMessage request, ModuleViewModel moduleVm)
        {
            return(CreateHttpResponse(request, () =>
            {
                HttpResponseMessage response = null;
                Module moduleDb = new Module();
                moduleDb.UpdateModule(moduleVm);
                _moduleService.Create(moduleDb);
                _moduleService.Save();

                if (moduleVm.Payload == Common.CommonConstants.ModuleAdminContact)
                {
                    MdAdminContact mdAdminContact = new MdAdminContact();
                    mdAdminContact.BotID = moduleVm.BotID;
                    mdAdminContact.MessageStart1 = "Đã thoát trả lời tự động";
                    mdAdminContact.MessageStart2 = "Anh/chị cần tư vấn hay hỗ trợ gì ạ";
                    mdAdminContact.MessageStart3 = "Anh/chị vui lòng chờ một chút, em sẽ chuyển cho chuyên viên hỗ trợ anh/chị ngay";
                    mdAdminContact.ModuleID = moduleDb.ID;
                    //mdPhone.CardPayloadID = null;
                    //mdPhone.Payload = "";
                    mdAdminContact.Title = "Xử lý liên hệ admin";
                    mdAdminContact.DictionaryKey = "admin_contact";
                    mdAdminContact.DictionaryValue = "false";

                    _mdAdminContactService.Create(mdAdminContact);
                    _mdAdminContactService.Save();
                }

                if (moduleVm.Payload == Common.CommonConstants.ModuleEngineerName)
                {
                    MdEngineerName mdEngineerName = new MdEngineerName();
                    mdEngineerName.BotID = moduleVm.BotID;
                    mdEngineerName.MessageStart = "Vui lòng nhập tên kỹ thuật viên nếu có.";
                    mdEngineerName.MessageError = "Không tìm thấy";
                    mdEngineerName.MessageEnd = "Đã nhận thông tin";
                    mdEngineerName.ModuleID = moduleDb.ID;
                    //mdPhone.CardPayloadID = null;
                    //mdPhone.Payload = "";
                    mdEngineerName.Title = "Xử lý tên kỹ sư";
                    mdEngineerName.DictionaryKey = "engineer_name";
                    mdEngineerName.DictionaryValue = "false";

                    _mdEngineerNameService.Create(mdEngineerName);
                    _mdEngineerNameService.Save();
                }

                if (moduleVm.Payload == Common.CommonConstants.ModulePhone)
                {
                    MdPhone mdPhone = new MdPhone();
                    mdPhone.BotID = moduleVm.BotID;
                    mdPhone.MessageStart = "Vui lòng nhập số điện thoại của bạn hoặc chọn bên dưới nếu có.";
                    mdPhone.MessageError = "Số điện thoại không hợp lệ, vui lòng nhập lại!";
                    mdPhone.MessageEnd = "Chúng tôi đã nhận được số điện thoại của bạn. Cảm ơn!";
                    mdPhone.ModuleID = moduleDb.ID;
                    //mdPhone.CardPayloadID = null;
                    //mdPhone.Payload = "";
                    mdPhone.Title = "Xử lý số điện thoại";
                    mdPhone.DictionaryKey = "phone";
                    mdPhone.DictionaryValue = "false";

                    _mdPhoneService.Create(mdPhone);
                    _mdPhoneService.Save();
                }
                if (moduleVm.Payload == Common.CommonConstants.ModuleEmail)
                {
                    MdEmail mdEmail = new MdEmail();
                    mdEmail.BotID = moduleVm.BotID;
                    mdEmail.MessageStart = "Vui lòng nhập email của bạn hoặc chọn bên dưới nếu có.";
                    mdEmail.MessageError = "Địa chỉ email không hợp lệ, vui lòng nhập lại!";
                    mdEmail.MessageEnd = "Cảm ơn bạn đã cung cấp thông tin!";
                    mdEmail.ModuleID = moduleDb.ID;
                    //mdPhone.CardPayloadID = null;
                    //mdPhone.Payload = "";
                    mdEmail.Title = "Xử lý email";
                    mdEmail.DictionaryKey = "email";
                    mdEmail.DictionaryValue = "false";

                    _mdEmailService.Create(mdEmail);
                    _mdEmailService.Save();
                }
                if (moduleVm.Payload == Common.CommonConstants.ModuleAge)
                {
                    MdAge mdAge = new MdAge();
                    mdAge.BotID = moduleVm.BotID;
                    mdAge.MessageStart = "Bạn vui lòng cho tôi biết độ tuổi của bạn.";
                    mdAge.MessageError = "Tôi không nghĩ đó là số tuổi, bạn vui lòng nhập vào chữ số.";
                    mdAge.MessageEnd = "Cảm ơn bạn, chúng tôi đã tiếp nhận thông tin thành công!";
                    mdAge.ModuleID = moduleDb.ID;
                    //mdPhone.CardPayloadID = null;
                    //mdPhone.Payload = "";
                    mdAge.Title = "Xử lý tuổi";
                    mdAge.DictionaryKey = "age";
                    mdAge.DictionaryValue = "false";

                    _mdAgeService.Create(mdAge);
                    _mdAgeService.Save();
                }
                //if (moduleVm.Payload == Common.CommonConstants.ModuleVoucher)
                //{
                //    MdVoucher mdVoucher = new MdVoucher();
                //    mdVoucher.BotID = moduleVm.BotID;
                //    mdVoucher.MessageStart = "Bạn vui lòng nhập số điện thoại để nhận voucher.";
                //    mdVoucher.MessageError = "Số điện thoại không đúng, bạn vui lòng nhập lại.";
                //    mdVoucher.MessageEnd = "Cảm ơn bạn, chúng đã tiếp nhận thông tin thành công!";
                //    mdVoucher.ModuleID = moduleDb.ID;
                //    //mdPhone.CardPayloadID = null;
                //    //mdPhone.Payload = "";
                //    mdVoucher.Title = "Xử lý voucher";
                //    mdVoucher.DictionaryKey = "voucher";
                //    mdVoucher.DictionaryValue = "false";

                //    _mdVoucherService.Create(mdVoucher);
                //    _mdVoucherService.Save();
                //}

                response = request.CreateResponse(HttpStatusCode.OK, moduleDb);
                return response;
            }));
        }
Exemple #2
0
 public void Update(MdEngineerName module)
 {
     _mdEngineerNameRepository.Update(module);
 }
Exemple #3
0
        public HttpResponseMessage CreateModuleEngineerName(HttpRequestMessage request, MdEngineerName mdEngineerName)
        {
            return(CreateHttpResponse(request, () =>
            {
                HttpResponseMessage response = null;

                var module = _mdEngineerNameService.GetByBotID(mdEngineerName.BotID);
                module.MessageStart = mdEngineerName.MessageStart;
                module.MessageError = mdEngineerName.MessageError;
                module.MessageEnd = mdEngineerName.MessageEnd;
                module.CardPayloadID = mdEngineerName.CardPayloadID;
                module.TitlePayload = mdEngineerName.TitlePayload;
                if (mdEngineerName.CardPayloadID != null && mdEngineerName.CardPayloadID != 0)
                {
                    module.Payload = "postback_card_" + mdEngineerName.CardPayloadID;
                }
                else
                {
                    module.Payload = "";
                }

                _mdEngineerNameService.Update(module);
                _mdEngineerNameService.Save();
                response = request.CreateResponse(HttpStatusCode.OK, module);
                return response;
            }));
        }
Exemple #4
0
 public MdEngineerName Create(MdEngineerName module)
 {
     return(_mdEngineerNameRepository.Add(module));
 }