Exemplo n.º 1
0
 private ConfigurationState()
 {
     Ui       = new UiSection();
     Logger   = new LoggerSection();
     System   = new SystemSection();
     Graphics = new GraphicsSection();
     Hid      = new HidSection();
     EnableDiscordIntegration = new ReactiveObject <bool>();
 }
 public ActionResult Delete(int id)
 {
     using (DBModel db = new DBModel())
     {
         SystemSection section = db.SystemSections.Where(x => x.SystemSectionId == id).FirstOrDefault <SystemSection>();
         db.SystemSections.Remove(section);
         db.SaveChanges();
         return(Json(new { success = true, message = "Deleted Successfuly" }, JsonRequestBehavior.AllowGet));
     }
 }
Exemplo n.º 3
0
 private ConfigurationState()
 {
     Ui       = new UiSection();
     Logger   = new LoggerSection();
     System   = new SystemSection();
     Graphics = new GraphicsSection();
     Hid      = new HidSection();
     EnableDiscordIntegration = new ReactiveObject <bool>();
     CheckUpdatesOnStart      = new ReactiveObject <bool>();
     ShowConfirmExit          = new ReactiveObject <bool>();
     HideCursorOnIdle         = new ReactiveObject <bool>();
 }
 public ActionResult AddOrEditSystemSection(SystemSection section)
 {
     using (DBModel db = new DBModel())
     {
         if (section.SystemSectionId == 0)
         {
             db.SystemSections.Add(section);
             db.SaveChanges();
             //return Json(new { success = true, message = "Saved Successfully" }, JsonRequestBehavior.AllowGet);
             return(View("IndexSystemSection"));
         }
         else
         {
             db.Entry(section).State = EntityState.Modified;
             db.SaveChanges();
             //return Json(new { success = true, message = "Updated Successfully" }, JsonRequestBehavior.AllowGet);
             return(View("IndexSystemSection"));
         }
     }
 }
Exemplo n.º 5
0
        /// <summary>
        /// 添加
        /// </summary>
        /// <param name="requestModel"></param>
        /// <returns></returns>
        public BusinessBaseViewModel <string> Insert(AddSystemSectionRequestModel requestModel)
        {
            var res = new BusinessBaseViewModel <string>()
            {
                Status = ResponseStatus.Fail
            };

            if (requestModel == null)
            {
                res.ErrorMessage = "参数错误";
                return(res);
            }
            if (requestModel.Name.IsNullOrWhiteSpace())
            {
                res.ErrorMessage = "部门名称不能为空";
                return(res);
            }
            var entity = _systemSectionRepository.FirstOrDefault(x => x.Name == requestModel.Name && x.ParentId == requestModel.ParentId);

            if (entity != null)
            {
                res.ErrorMessage = "部门名称已存在,不能重复添加";
                return(res);
            }
            int level = 1;

            if (requestModel.ParentId > 0)
            {
                level = _systemSectionRepository.FirstOrDefault(x => x.Id == requestModel.ParentId).Level + 1;
            }

            var Code = 0;

            var query = _systemSectionRepository.Find(x => x.ParentCode == requestModel.ParentCode);

            if (query.Any())
            {
                var maxCode = query.Max(x => x.Code);

                //如果不是第一级
                if (requestModel.ParentCode != 0)
                {
                    maxCode = requestModel.ParentCode * 100 + 1;
                }
                maxCode += 1;

                Code = maxCode;
            }
            else
            {
                Code = requestModel.ParentCode * 100 + 1;
            }

            var model = new SystemSection()
            {
                Name       = requestModel.Name,
                Person     = requestModel.Person,
                ParentId   = requestModel.ParentId,
                Code       = Code,
                ParentCode = requestModel.ParentCode,
                Enabled    = requestModel.Enabled,
                Sort       = requestModel.Sort,
                Level      = level,
                CreateTime = DateTime.Now,
                ModifyTime = DateTime.Now,
                Remark     = requestModel.Remark
            };

            _systemSectionRepository.Insert(model);
            _systemSectionRepository.SaveChanges();

            res.Status = ResponseStatus.Success;
            return(res);
        }