Пример #1
0
        public ActionResult EditSms(int id = 0)
        {
            using (var db = new XkSystem.Models.DbContext())
            {
                var vm = new Models.Sms.EditSms();
                if (id != 0)
                {
                    var tb = (from p in db.Table <Entity.tbSms>()
                              where p.Id == id
                              select new Dto.Sms.EditSms
                    {
                        Id = p.Id,
                        SmsTitle = p.SmsTitle,
                        PlanDate = p.PlanDate,
                        SysUserId = p.tbSysUser.Id
                    }).FirstOrDefault();
                    if (tb != null)
                    {
                        vm.SmsEdit = tb;
                    }
                }

                return(View(vm));
            }
        }
Пример #2
0
 public ActionResult EditSms(Models.Sms.EditSms vm)
 {
     using (var db = new XkSystem.Models.DbContext())
     {
         var error = new List <string>();
         if (error.Count == decimal.Zero)
         {
             if (vm.SmsEdit.Id > 0)
             {
                 var tb = (from p in db.Table <Entity.tbSms>()
                           where p.Id == vm.SmsEdit.Id
                           select p).FirstOrDefault();
                 if (tb != null)
                 {
                     tb.InputDate = DateTime.Now;
                     tb.PlanDate  = vm.SmsEdit.PlanDate;
                     tb.SmsTitle  = vm.SmsEdit.SmsTitle;
                     tb.tbSysUser = db.Set <Sys.Entity.tbSysUser>().Find(Code.Common.UserId);
                     if (db.SaveChanges() > 0)
                     {
                         XkSystem.Areas.Sys.Controllers.SysUserLogController.Insert("修改了短信");
                     }
                 }
                 else
                 {
                     error.AddError(Resources.LocalizedText.MsgNotFound);
                 }
             }
         }
         var vmList = new Models.Sms.List();
         return(Code.MvcHelper.Post(error, Url.Action("List", new
         {
             searchText = vmList.SearchText,
             dateSearchFrom = vmList.DateSearchFrom,
             dateSearchTo = vmList.DateSearchTo,
             pageIndex = vmList.Page.PageIndex,
             pageSize = vmList.Page.PageSize
         })));
     }
 }