Exemplo n.º 1
0
        public BOTS_TblWAConfig GetCommunicationWAConfig(string GroupId, string BrandId)
        {
            BOTS_TblWAConfig objData = new BOTS_TblWAConfig();

            using (var context = new CommonDBContext())
            {
                if (BrandId != "0")
                {
                    objData = context.BOTS_TblWAConfig.Where(x => x.GroupId == GroupId && x.BrandId == BrandId).FirstOrDefault();
                }
                else
                {
                    objData = context.BOTS_TblWAConfig.Where(x => x.GroupId == GroupId && x.BrandId == "All").FirstOrDefault();
                }
            }

            return(objData);
        }
Exemplo n.º 2
0
        public bool SaveCommunicationConfig(BOTS_TblSMSConfig objSMSData, BOTS_TblWAConfig objWAData)
        {
            bool status = false;

            using (var context = new CommonDBContext())
            {
                using (DbContextTransaction transaction = context.Database.BeginTransaction())
                {
                    try
                    {
                        if (objSMSData.IsSMS)
                        {
                            if (objSMSData.BrandId == "All")
                            {
                                var allBrandData = context.BOTS_TblSMSConfig.Where(x => x.BrandId != "All").ToList();
                                foreach (var item in allBrandData)
                                {
                                    context.BOTS_TblSMSConfig.Remove(item);
                                    context.SaveChanges();
                                }
                            }
                            else
                            {
                                var allBrandData = context.BOTS_TblSMSConfig.Where(x => x.BrandId == "All").ToList();
                                foreach (var item in allBrandData)
                                {
                                    context.BOTS_TblSMSConfig.Remove(item);
                                    context.SaveChanges();
                                }
                            }
                            if (objSMSData.Id > 0)
                            {
                                var oldData = context.BOTS_TblSMSConfig.Where(x => x.Id == objSMSData.Id).FirstOrDefault();
                                if (oldData != null)
                                {
                                    objSMSData.AddedBy   = oldData.AddedBy;
                                    objSMSData.AddedDate = oldData.AddedDate;
                                }
                            }
                            context.BOTS_TblSMSConfig.AddOrUpdate(objSMSData);
                            context.SaveChanges();
                            status = true;
                        }
                        if (objWAData.IsWA)
                        {
                            if (objWAData.BrandId == "All")
                            {
                                var allBrandData = context.BOTS_TblWAConfig.Where(x => x.BrandId != "All").ToList();
                                foreach (var item in allBrandData)
                                {
                                    context.BOTS_TblWAConfig.Remove(item);
                                    context.SaveChanges();
                                }
                            }
                            else
                            {
                                var allBrandData = context.BOTS_TblWAConfig.Where(x => x.BrandId == "All").ToList();
                                foreach (var item in allBrandData)
                                {
                                    context.BOTS_TblWAConfig.Remove(item);
                                    context.SaveChanges();
                                }
                            }
                            if (objWAData.Id > 0)
                            {
                                var oldData = context.BOTS_TblWAConfig.Where(x => x.Id == objWAData.Id).FirstOrDefault();
                                if (oldData != null)
                                {
                                    objWAData.AddedBy   = oldData.AddedBy;
                                    objWAData.AddedDate = oldData.AddedDate;
                                }
                            }
                            context.BOTS_TblWAConfig.AddOrUpdate(objWAData);
                            context.SaveChanges();
                            status = true;
                        }

                        transaction.Commit();
                    }
                    catch (Exception ex)
                    {
                        transaction.Rollback();
                        newexception.AddException(ex, "SaveCommunicationConfig");
                    }
                }
            }


            return(status);
        }
Exemplo n.º 3
0
        public ActionResult SaveCommunicationConfig(string jsonData)
        {
            bool status = false;

            try
            {
                var userDetails = (CustomerLoginDetail)Session["UserSession"];
                BOTS_TblSMSConfig    objSMSConfig    = new BOTS_TblSMSConfig();
                BOTS_TblWAConfig     objWAConfig     = new BOTS_TblWAConfig();
                JavaScriptSerializer json_serializer = new JavaScriptSerializer();
                json_serializer.MaxJsonLength = int.MaxValue;
                object[] objCommConfigData = (object[])json_serializer.DeserializeObject(jsonData);
                foreach (Dictionary <string, object> item in objCommConfigData)
                {
                    var isSMS = Convert.ToBoolean(item["IsSMS"]);
                    if (isSMS)
                    {
                        objSMSConfig.IsSMS = true;
                        if (!string.IsNullOrEmpty(Convert.ToString(item["SMSId"])))
                        {
                            objSMSConfig.Id = Convert.ToInt32(item["SMSId"]);
                        }
                        objSMSConfig.SMSProvider             = Convert.ToString(item["SMSProvider"]);
                        objSMSConfig.GroupId                 = Convert.ToString(item["GroupId"]);
                        objSMSConfig.BrandId                 = Convert.ToString(item["BrandId"]);
                        objSMSConfig.SMSSenderID             = Convert.ToString(item["SMSSenderId"]);
                        objSMSConfig.SMSUsername             = Convert.ToString(item["SMSUserName"]);
                        objSMSConfig.SMSPassword             = Convert.ToString(item["SMSPassword"]);
                        objSMSConfig.SMSlink                 = Convert.ToString(item["SMSLink"]);
                        objSMSConfig.EnrolmentSMSScript      = Convert.ToString(item["SMSEnrollment"]);
                        objSMSConfig.EnrollmentEarnSMSScript = Convert.ToString(item["SMSEnrollmentAndEarn"]);
                        objSMSConfig.EarnSMSScript           = Convert.ToString(item["SMSEarn"]);
                        objSMSConfig.OTPSMSScript            = Convert.ToString(item["SMSOTP"]);
                        objSMSConfig.BurnSMSScript           = Convert.ToString(item["SMSBurn"]);
                        objSMSConfig.CancelEarnSMSScript     = Convert.ToString(item["SMSCancelEarn"]);
                        objSMSConfig.CancelBurnSMSScript     = Convert.ToString(item["SMSCancelBurn"]);
                        objSMSConfig.AnyCancelSMSScript      = Convert.ToString(item["SMSAnyCancel"]);
                        objSMSConfig.BalanceInquirySMSScript = Convert.ToString(item["SMSBalanceInquiry"]);
                        if (objSMSConfig.Id > 0)
                        {
                            objSMSConfig.UpdatedBy   = userDetails.LoginId;
                            objSMSConfig.UpdatedDate = DateTime.Now;
                        }
                        else
                        {
                            objSMSConfig.AddedBy   = userDetails.LoginId;
                            objSMSConfig.AddedDate = DateTime.Now;
                        }
                    }
                    else
                    {
                        objSMSConfig.IsSMS = false;
                    }
                    var isWA = Convert.ToBoolean(item["IsWA"]);
                    if (isWA)
                    {
                        objWAConfig.IsWA = true;
                        if (!string.IsNullOrEmpty(Convert.ToString(item["WAId"])))
                        {
                            objWAConfig.Id = Convert.ToInt32(item["WAId"]);
                        }
                        objWAConfig.WAProvider             = Convert.ToString(item["WAProvider"]);
                        objWAConfig.GroupId                = Convert.ToString(item["GroupId"]);
                        objWAConfig.BrandId                = Convert.ToString(item["BrandId"]);
                        objWAConfig.WANumber               = Convert.ToString(item["WANumber"]);
                        objWAConfig.WAUsername             = Convert.ToString(item["WAUserName"]);
                        objWAConfig.WAPassword             = Convert.ToString(item["WAPassword"]);
                        objWAConfig.WAlink                 = Convert.ToString(item["WALink"]);
                        objWAConfig.EnrolmentWAScript      = Convert.ToString(item["WAEnrollment"]);
                        objWAConfig.EnrollmentEarnWAScript = Convert.ToString(item["WAEnrollmentAndEarn"]);
                        objWAConfig.EarnWAScript           = Convert.ToString(item["WAEarn"]);
                        objWAConfig.OTPWAScript            = Convert.ToString(item["WAOTP"]);
                        objWAConfig.BurnWAScript           = Convert.ToString(item["WABurn"]);
                        objWAConfig.CancelEarnWAScript     = Convert.ToString(item["WACancelEarn"]);
                        objWAConfig.CancelBurnWAScript     = Convert.ToString(item["WACancelBurn"]);
                        objWAConfig.AnyCancelWAScript      = Convert.ToString(item["WAAnyCancel"]);
                        objWAConfig.BalanceInquiryWAScript = Convert.ToString(item["WABalanceInquiry"]);
                        if (objWAConfig.Id > 0)
                        {
                            objWAConfig.UpdatedBy   = userDetails.LoginId;
                            objWAConfig.UpdatedDate = DateTime.Now;
                        }
                        else
                        {
                            objWAConfig.AddedBy   = userDetails.LoginId;
                            objWAConfig.AddedDate = DateTime.Now;
                        }
                    }
                    else
                    {
                        objWAConfig.IsWA = false;
                    }
                }
                status = OBR.SaveCommunicationConfig(objSMSConfig, objWAConfig);
            }
            catch (Exception ex)
            {
            }
            return(new JsonResult()
            {
                Data = status, JsonRequestBehavior = JsonRequestBehavior.AllowGet, MaxJsonLength = Int32.MaxValue
            });
        }