Пример #1
0
        public ActionResult UpdateSysState(int state, string remark)
        {
            SetSystemDTO dto = setsysService.GetFirstModelByID();

            if (dto == null)
            {
                long a = setsysService.AddSetSystem(state, remark);
                if (a <= 0)
                {
                    return(Json(new AjaxResult {
                        Status = "0", Msg = "提交失败"
                    }));
                }
                return(Json(new AjaxResult {
                    Status = "1", Data = "/admin/system/SystemState"
                }));
            }
            else
            {
                int re = setsysService.UpdateSystem(dto.ID, state, remark);
                if (re == 0)
                {
                    return(Json(new AjaxResult {
                        Status = "1", Data = "/admin/system/SystemState"
                    }));
                }
                return(Json(new AjaxResult {
                    Status = "0", Msg = "提交失败"
                }));
            }
        }
Пример #2
0
        public ActionResult SystemState()
        {
            SetSystemDTO dto = setsysService.GetFirstModelByID();

            if (dto == null)
            {
                dto = new SetSystemDTO();
            }
            return(View(dto));
        }
Пример #3
0
        public SetSystemDTO ToDTO(SetSystemEntity model)
        {
            SetSystemDTO dto = new SetSystemDTO();

            dto.ID             = model.ID;
            dto.IsOpenWeb      = model.IsOpenWeb;
            dto.CloseWebRemark = model.CloseWebRemark;
            dto.CreateTime     = model.CreateTime;

            return(dto);
        }
Пример #4
0
 public SetSystemDTO GetFirstModelByID()
 {
     using (MyDbContext dbcontext = new MyDbContext())
     {
         CommonService <SetSystemEntity> cs = new CommonService <SetSystemEntity>(dbcontext);
         SetSystemEntity re    = cs.GetAll().FirstOrDefault();// cs.GetById(ID);
         SetSystemDTO    model = null;
         if (re != null)
         {
             model = ToDTO(re);
         }
         return(model);
     }
 }
Пример #5
0
 /// <summary>
 /// 根据ID查询
 /// </summary>
 /// <param name="ID"></param>
 /// <returns></returns>
 public SetSystemDTO GetModelByID(long ID)
 {
     using (MyDbContext dbcontext = new MyDbContext())
     {
         CommonService <SetSystemEntity> cs = new CommonService <SetSystemEntity>(dbcontext);
         SetSystemEntity re    = cs.GetById(ID);
         SetSystemDTO    model = null;
         if (re != null)
         {
             model = ToDTO(re);
         }
         return(model);
     }
 }