public ActionResult GetSmsToList(SmsSendRequestModel model)
        {
            using (var db = new XkSystem.Models.DbContext())
            {
                var vm = new Models.SmsTo.List();
                var tb = (from p in db.TableRoot <Entity.tbSmsTo>()
                          where (p.Status == decimal.Zero || p.Status == -decimal.One) &&
                          p.tbTenant.Id == model.TenantId &&
                          p.tbTenant.IsDeleted == false &&
                          p.tbSms.PlanDate.Day == DateTime.Now.Day
                          select p);

                var tbSmsToList = (from p in tb
                                   join m in db.TableRoot <Entity.tbSms>() on p.tbSms.Id equals m.Id into n
                                   from k in n.DefaultIfEmpty()
                                   orderby p.SendDate
                                   select new Dto.SmsTo.List
                {
                    Id = p.Id,
                    Mobile = p.Mobile,
                    No = p.No,
                    Remark = p.Remark,
                    Retry = p.Retry,
                    SmsId = p.tbSms.Id,
                    SmsTitle = k == null ? "" : k.SmsTitle,
                    Status = p.Status,
                    SendDate = p.SendDate,
                    SysUserName = p.tbSysUser.UserName
                }).Take(50).ToList();

                return(Json(tbSmsToList));
            }
        }
        public ActionResult SetSmsStatus(SmsSendRequestModel model)
        {
            using (var db = new XkSystem.Models.DbContext())
            {
                if (model.SmsResponseList != null && model.SmsResponseList.Count > decimal.Zero)
                {
                    var ids         = model.SmsResponseList.Select(d => d.SmsId).ToList();
                    var tbSmsToList = (from p in db.TableRoot <Entity.tbSmsTo>()
                                       where ids.Contains(p.Id) && p.tbTenant.Id == model.TenantId
                                       select p).ToList();

                    foreach (var sms in tbSmsToList)
                    {
                        var smsStatus = model.SmsResponseList.Where(d => d.SmsId == sms.Id).FirstOrDefault();
                        if (smsStatus == null)
                        {
                            continue;
                        }
                        else
                        {
                            if (smsStatus.IsSuccess)
                            {
                                sms.Status   = decimal.One;
                                sms.SendDate = string.IsNullOrEmpty(smsStatus.SendDate) ? DateTime.Now : smsStatus.SendDate.ConvertToDateTime();
                                sms.Retry    = sms.Retry + 1;
                            }
                            else
                            {
                                sms.Status   = -decimal.One;
                                sms.SendDate = string.IsNullOrEmpty(smsStatus.SendDate) ? DateTime.Now : smsStatus.SendDate.ConvertToDateTime();
                                sms.Retry    = sms.Retry + 1;
                                sms.Remark   = smsStatus.errorMsg;
                            }
                        }
                    }
                    db.SaveChanges();
                }
                return(Json(new { IsSuccess = true }));
            }
        }