public void AddOrUpdateAllAuthFunctionInfo(AuthFunctionInfoModel model) { if (model.FunctionId.HasValue) { using (var scope = AutoEfRepositoryFactory.GetEfRepositoryFactory(DataSources.DataSource_ItAdmin).CreateReadWriteContextScope()) { var funcInfo = this._efAuthFunctionInfoRepository.GetById(model.FunctionId.Value); funcInfo.Code = model.Code; funcInfo.Name = model.Name; funcInfo.Desc = model.Desc; funcInfo.UpdateTime = DateTime.Now; funcInfo.IsEnable = model.IsEnable; this._efAuthFunctionInfoRepository.Update(funcInfo); scope.SaveChanges(); } } else { this._efAuthFunctionInfoRepository.Insert(new AuthFunctionInfoEntity { Id = Guid.NewGuid(), Code = model.Code, CreateTime = DateTime.Now, Desc = model.Desc, IsEnable = model.IsEnable, Name = model.Name, UpdateTime = DateTime.Now, ParentId = model.ParentId, AppId = model.AppId }); } }
public ActionResult AuthFunctionInfoAdd(Guid parentId, Guid appId) { var model = new AuthFunctionInfoModel(); model.ParentId = parentId; model.AppId = appId; return(View("AppFunctionInfoAdd")); }
public ActionResult SaveAuthFunctionInfo(AuthFunctionInfoModel model) { InkeyResult result = new InkeyResult(); string errorMessage; if (this.VerifyModle(out errorMessage)) { this._authManagerService.AddOrUpdateAllAuthFunctionInfo(model); } else { result.Code = -101; result.Desc = errorMessage; } return(Json(result)); }
public IList <AuthFunctionInfoModel> GetSubAuthFunctionInfoList(Guid appId, Guid parentId) { var db = this._efAuthFunctionInfoRepository.TableNoTracking; if (parentId == Guid.Empty) { var list = db.Where(func => func.ParentId == parentId && func.AppId == appId).ToList().Select(func => { var model = new AuthFunctionInfoModel(); model.ParentId = parentId; model.FunctionId = func.Id; model.Code = func.Code; model.Name = func.Name; model.Desc = func.Desc; model.IsEnable = func.IsEnable; model.CreateTime = func.CreateTime; model.UpdateTime = func.UpdateTime; model.ParentParentId = parentId; return(model); }).ToList(); return(list); } var functionInfo = db.Include(func => func.SubAuthFunctionInfos).Where(func => func.AppId == appId && func.Id == parentId).FirstOrDefault(); if (functionInfo == null) { return(new List <AuthFunctionInfoModel>()); } return(functionInfo.SubAuthFunctionInfos.Select(func => { var model = new AuthFunctionInfoModel(); model.ParentId = parentId; model.FunctionId = func.Id; model.Code = func.Code; model.Name = func.Name; model.Desc = func.Desc; model.IsEnable = func.IsEnable; model.CreateTime = func.CreateTime; model.UpdateTime = func.UpdateTime; model.ParentParentId = functionInfo.ParentId; return model; }).ToList()); }