コード例 #1
0
 public ViewResult Edit(iPow.Infrastructure.Crosscutting.Authorize.Dto.MvcControllerDto MvcController, string State)
 {
     ViewBag.Controllermodel = mvcControllerClassService.GetList();
     try
     {
         if (MvcController != null && MvcController.Id > 0)
         {
             //根据Id得到当前
             var model = mvcControllerService.GetControllerSingleById(MvcController.Id);
             model.ClassId = MvcController.ClassId;
             model.Remark  = MvcController.Remark;
             model.State   = Convert.ToBoolean(State);
             model.SortNum = MvcController.SortNum;
             //执行更新吧
             mvcControllerService.Modify(model, null);
             var dto = model.ToDto();
             ModelState.AddModelError("", "恭喜,亲彻底Hold住了");
             return(View(dto));
         }
     }
     catch
     {
         ModelState.AddModelError("", "败笔!亲不给力哦~");
     }
     return(View(MvcController));
 }
コード例 #2
0
 public ViewResult Add(iPow.Infrastructure.Crosscutting.Authorize.Dto.MvcControllerDto MvcController, string State)
 {
     //做为 DropDownList DataSource
     ViewBag.Controllermodel = mvcControllerClassService.GetList();
     if (MvcController != null)
     {
         var mvcclass = mvcControllerClassService.GetClassModelById(MvcController.ClassId);
         //MvcController.ClassName = mvcclass.Name;
         //根据Name查询
         var ControllerByName = mvcControllerService.GetList().Where(e => e.Name == MvcController.Name).FirstOrDefault();
         if (ControllerByName == null)
         {
             //判断Controller 是否存在当前所选Role  若没有则创建 有的话 阻止
             var isexist = mvcControllerService.ClassNameAndControllerNameHasController(MvcController.ClassId, MvcController.Name);
             if (isexist)  //该语法表示 已经存在
             {
                 ModelState.AddModelError("", "该该控制器已经存在同一分类!");
             }
             else
             {
                 iPow.Infrastructure.Data.DataSys.Sys_MvcController addController = new iPow.Infrastructure.Data.DataSys.Sys_MvcController();
                 addController.ClassId          = MvcController.ClassId;
                 addController.Name             = MvcController.Name;
                 addController.AssemblyFullName = addController.Name;
                 addController.Remark           = addController.Name;
                 MvcController.AddTime          = System.DateTime.Now;
                 addController.AddTime          = MvcController.AddTime;
                 addController.IpAddress        = iPow.Infrastructure.Crosscutting.Function.StringHelper.GetRealIP();
                 addController.State            = Convert.ToBoolean(State);
                 addController.SortNum          = MvcController.SortNum;
                 mvcControllerService.Add(addController, null);
                 if (addController.Id > 0)
                 {
                     ModelState.AddModelError("", "恭喜,亲彻底Hold住了");
                 }
                 else
                 {
                     ModelState.AddModelError("", "败笔!亲不给力哦~");
                 }
             }
         }
         else
         {
             ModelState.AddModelError("", "添加控制器失败 ");
         }
     }
     else
     {
         ModelState.AddModelError("", "亲请使用楷体字用力填写");
     }
     return(View(MvcController));
 }