Beispiel #1
0
        public ActionResult UpdateSMSIDPass(SMSSenderIDPass smsSenderIdPass)
        {
            SMSSenderIDPass SMSSenderIDPass = db.SMSSenderIDPass.FirstOrDefault();

            try
            {
                if (SMSSenderIDPass == null)
                {
                    smsSenderIdPass.CreateBy   = AppUtils.GetLoginEmployeeName();
                    smsSenderIdPass.CreateDate = AppUtils.dateTimeNow;
                    db.SMSSenderIDPass.Add(smsSenderIdPass);
                    db.SaveChanges();
                }
                else
                {
                    smsSenderIdPass.Status            = SMSSenderIDPass.Status;
                    smsSenderIdPass.SMSSenderIDPassID = SMSSenderIDPass.SMSSenderIDPassID;
                    smsSenderIdPass.CreateBy          = AppUtils.GetLoginEmployeeName();
                    smsSenderIdPass.CreateDate        = AppUtils.dateTimeNow;
                    smsSenderIdPass.UpdateBy          = AppUtils.GetLoginEmployeeName();
                    smsSenderIdPass.UpdateDate        = AppUtils.dateTimeNow;
                    db.Entry(SMSSenderIDPass).CurrentValues.SetValues(smsSenderIdPass);
                    db.SaveChanges();
                }

                return(Json(new { Success = true }));
            }
            catch (Exception ex)
            {
                return(Json(new { Success = false }));
            }
        }
Beispiel #2
0
        public ActionResult SMSIDPass()
        {
            SMSSenderIDPass smsSenderIdPass = db.SMSSenderIDPass.FirstOrDefault();

            // ViewBag.ID = smsSenderIdPass!= null ? smsSenderIdPass.ID : "";
            //ViewBag.pass = smsSenderIdPass!= null ? smsSenderIdPass.Pass : "";
            //ViewBag.Sender = smsSenderIdPass!= null ? smsSenderIdPass.Sender : "";
            //  ViewBag.CompanyName = smsSenderIdPass!= null ? smsSenderIdPass.CompanyName : "";
            //  ViewBag.HelpLine = smsSenderIdPass != null ? smsSenderIdPass.HelpLine : "";
            return(View(smsSenderIdPass));
        }
Beispiel #3
0
        public ActionResult SendSMSToClient(string message, bool IsCheckAll, string[] IfIsCheckAllThenNonCheckList, string[] IfNotCheckAllThenCheckList, int ForWhichTypeSMSIsThat, int UserType = 0, int ZoneID = 0)
        {
            try
            {
                List <ClientDetails> lstClientDetails = new List <ClientDetails>();
                if (IsCheckAll)
                {
                    var clientDetails = db.ClientDetails.AsQueryable();
                    if (UserType != 0 && ZoneID != 0)
                    {
                        clientDetails = clientDetails.Where(x => x.Status == UserType && x.ZoneID == ZoneID).AsQueryable();
                    }
                    else if (UserType != 0)
                    {
                        clientDetails = clientDetails.Where(x => x.Status == UserType).AsQueryable();
                    }
                    else if (ZoneID != 0)
                    {
                        clientDetails = clientDetails.Where(x => x.ZoneID == ZoneID).AsQueryable();
                    }
                    else
                    {
                        var test = "";
                    }

                    if (IfIsCheckAllThenNonCheckList != null)
                    {
                        List <int> lstClientDetailsInInt = IfIsCheckAllThenNonCheckList.Select(int.Parse).ToList();
                        //lstClientDetails = clientDetails/*.AsEnumerable().Where(x => !lstClientDetailsInInt.Contains(x.ClientDetailsID))*/.ToList();
                        var lstClientPhoneNumberWithID = clientDetails.Where(x => !lstClientDetailsInInt.Contains(x.ClientDetailsID)).Select(x => new SendSMSCustomInformation {
                            ClientID = x.ClientDetailsID, Phone = x.ContactNumber
                        }).ToList();
                        //var lstClientDetails2 = clientDetails.ToList().Where(x => !lstClientDetailsInInt.Contains(x.ClientDetailsID)).ToList();
                        //lstClientDetails = clientDetails.ToList();
                        Session["IdListForSMSSend"] = lstClientPhoneNumberWithID;
                    }
                    else
                    {
                        Session["IdListForSMSSend"] = clientDetails.Select(x => new SendSMSCustomInformation {
                            ClientID = x.ClientDetailsID, Phone = x.ContactNumber
                        }).ToList();
                    }
                }
                else
                {
                    if (IfNotCheckAllThenCheckList != null)
                    {
                        //var clientList = db.ClientDetails.Where(x => IfNotCheckAllThenCheckList.Any(o => o == x.ClientDetailsID.ToString()));

                        List <int> lstClientDetailsInInt      = IfNotCheckAllThenCheckList.Select(int.Parse).ToList();
                        var        clientList                 = db.ClientDetails.Where(x => lstClientDetailsInInt.Contains(x.ClientDetailsID));
                        var        lstCLientPhoneNumberWithID = clientList.Select(x => new SendSMSCustomInformation {
                            ClientID = x.ClientDetailsID, Phone = x.ContactNumber
                        }).ToList();

                        Session["IdListForSMSSend"] = lstCLientPhoneNumberWithID;
                    }
                }
                //var aa = clientDetails.ToList();

                List <string> lstMobileNumber             = new List <string>();
                List <SendSMSCustomInformation> clnIdList = Session["IdListForSMSSend"] as List <SendSMSCustomInformation>;
                List <SendSMSCustomInformation> lsttemp   = new List <SendSMSCustomInformation>();
                //if (IsCheckAll)
                //{
                //    if (IfIsCheckAllThenNonCheckList != null)
                //    {
                //        lsttemp = clnIdList.Where(x => !IfIsCheckAllThenNonCheckList.Contains(x.ClientID.ToString())).ToList();
                //    }
                //    else
                //    {
                //        lsttemp = clnIdList;
                //    }
                //}
                //else
                //{
                //    if (IfNotCheckAllThenCheckList != null)
                //    {
                //        lsttemp = clnIdList.Where(x => IfNotCheckAllThenCheckList.Contains(x.ClientID.ToString())).ToList(); ;
                //    }
                //    //else
                //    //{
                //    //    lsttemp = clnIdList;
                //    //}
                //}

                //if (IsCheckAll)
                //{
                //    if (IfIsCheckAllThenNonCheckList != null)
                //    {
                //        clnIdList.RemoveAll(x => IfIsCheckAllThenNonCheckList.Contains(x.ClientID.ToString()));
                //    }
                //}
                //else
                //{
                //    if (IfNotCheckAllThenCheckList != null)
                //    {
                //        clnIdList.RemoveAll(x => !IfNotCheckAllThenCheckList.Contains(Convert.ToString(x.ClientID)));
                //    }
                //}
                //List<SendSMSCustomInformation> lsttemp2 = TempData["IdListForSMSSendTemp"] as List<SendSMSCustomInformation>;
                //OptionSettings os = db.OptionSettings.Where(s => s.OptionSettingsName == AppUtils.SMSOptionName && s.Status == AppUtils.SendSMSStatusTrue).FirstOrDefault();
                if ((bool)Session["SMSOptionEnable"])
                {
                    foreach (var client in clnIdList)
                    {
                        try
                        {
                            //send sms here

                            SMSSenderIDPass smsSenderIdPass = db.SMSSenderIDPass.Where(s => s.Status == AppUtils.SMSGlobalStatusIsTrue).FirstOrDefault();
                            if (smsSenderIdPass != null)
                            {
                                SMSReturnDetails SMSReturnDetailsClient = AppUtils.SendSMS(smsSenderIdPass.Sender, smsSenderIdPass.ID, smsSenderIdPass.Pass, client.Phone, message);
                                if (SMSReturnDetailsClient.statusCode == AppUtils.ReturnMessageStatusCodeIsSuccess)
                                {
                                }
                                else
                                {
                                    lstMobileNumber.Add(client.Phone);
                                }
                            }
                        }
                        catch (Exception e)
                        {
                            lstMobileNumber.Add(client.Phone);
                        }
                    }
                }
                return(Json(new { sendSMSSuccess = true, lstMobileUnableToSendSMS = lstMobileNumber }, JsonRequestBehavior.AllowGet));
            }
            catch (Exception ex)
            {
                return(Json(new { sendSMSFail = true }, JsonRequestBehavior.AllowGet));
            }
        }