public ActionResult Add(string NAME, int IS_NEW, int STATUS, int POSITION, int MODULE_ID, string LINKURL) { string res = "Failed"; var a = (UserDto)Session["Account"]; var helperBo = new HelperBo(); var resExist = helperBo.IsExistWhere(tableName, "NAME='" + NAME + "'"); var statusVal = STATUS == 1 ? true : false; var isNewVal = IS_NEW == 1 ? true : false; if (resExist.message == "0") { var dto = new FunctionDto() { NAME = NAME, STATUS = statusVal, IS_NEW = isNewVal, POSITION = POSITION, MODULE_ID = MODULE_ID, LINKURL = LINKURL, MODIFIED_BY = Int32.Parse(a.Username), MODIFIED_AT = DateTime.Now.FormatYYYYMMDD() }; // not exist var resultAdd = helperBo.Add(tableName, dto); if (resultAdd.success == true) { res = "success"; } } return(Content(JsonConvert.SerializeObject(new { isSuccess = res }), "application/json")); }
public async Task OnGetAsync(long?id, long?pid) { if (id.HasValue) { Dto = await _service.GetByIdAsync(id.Value); if (Dto == null) { throw new VinoDataNotFoundException(); } if (Dto.ParentId.HasValue) { Parents = await _service.GetParentsAsync(Dto.ParentId.Value); } ViewData["Mode"] = "Edit"; } else { Dto = new FunctionDto(); if (pid.HasValue) { Dto.ParentId = pid.Value; Parents = await _service.GetParentsAsync(pid.Value); } else { Dto.ParentId = null; } ViewData["Mode"] = "Add"; } }
public async Task <ResponseResult <int> > Post(FunctionDto dto) { var item = await _functionService.AddOrUpdate <FunctionDto, int>(dto); var result = new ResponseResult <int>(item.Id); return(result); }
public IActionResult GetAllFunction() { var function = _service.GetAllFunction(); List <FunctionDto> Dto = new List <FunctionDto>(); foreach (var item in function) { FunctionDto Dtos = _mapper.Map <FunctionDto>(item); Dto.Add(Dtos); } return(Ok(Dto)); }
public IActionResult UpdateFunction(int id, [FromBody] FunctionDto functionDto) { var function = _mapper.Map <Function>(functionDto); try { _service.Update(function, id); return(Ok()); } catch (AppException ex) { return(BadRequest(new { message = ex.Message })); } }
public IActionResult DeleteFunction(int id, [FromBody] FunctionDto functionDto) { var function = _mapper.Map <Function>(functionDto); try { _service.Delete(id); return(Ok("Record Deleted Successfully..")); } catch (AppException ex) { return(BadRequest(new { message = ex.Message })); } }
///TODO- need to add this profile fields in db and api public IActionResult GetFunctionByID(int id) { var function = _service.GetById(id); if (function == null) { return(new UnauthorizedResult()); } FunctionDto functionDto = new FunctionDto() { ID = function.ID, Name = function.Name }; return(Ok(functionDto)); }
public ActionResult Edit(int id) { var list = new List <ModuleDto>(); var helperBo = new HelperBo(); var rest = helperBo.SelectWhere(null, "module", null, null); if (rest.data != null) { var tmp = rest.data[0]; var t1 = new ModuleDto(); t1.ID = tmp.Id; t1.Name = tmp.Name; t1.Description = tmp.Description; t1.Status = tmp.Status == 1 ? true : false; t1.ModifiedBy = tmp.ModifiedBy; t1.ModifiedDate = tmp.ModifiedDate.ToString(); t1.position = tmp.position; t1.Icon = tmp.Icon; list.Add(t1); } else { _log.Error("Error", rest.error.exception); } ViewBag.listModule = list; var t = new FunctionDto(); var res2 = helperBo.SelectWhere(null, tableName, "ID=" + id, null); if (res2.data != null) { var res = res2.data[0]; t.ID = res.ID; t.NAME = res.NAME; t.MODULE_ID = res.MODULE_ID; t.STATUS = res.STATUS == 1?true:false; t.MODIFIED_BY = Int32.Parse(res.MODIFIED_BY); t.MODIFIED_AT = res.MODIFIED_AT.ToString(); t.POSITION = res.POSITION; t.IS_NEW = res.IS_NEW == 1?true:false; t.LINKURL = res.LINKURL; } return(View(t)); }
public StandardJsonResult UpdateFunc(FunctionDto model) { var res = new StandardJsonResult <int>(); res.Try(() => { if (model.FunctionID == null || model.FunctionID.Equals("")) { res.Success = false; res.Message = "参数不合法"; res.Value = -1; } else { res.Value = _functionManagementService.Update(model); } }); return(res); }
//public List<RFAFunction> Select(Expression<Func<RFAFunction, bool>> foo) //{ // using (var db = new BCBackContext()) // { // List<RFAFunction> list = new List<RFAFunction>(); // list = db.RFAFunctions.Where(foo).ToList<RFAFunction>(); // return list; // } //} public int Update(FunctionDto obj) { using (var db = new BCBackContext()) { RFAFunction temp = db.RFAFunctions.Where(objx => objx.FunctionID.Equals(obj.FunctionID)).First(); if (temp == null) { return(0); } //temp.FunctionID = obj.FunctionID; temp.MyID = obj.MyID; temp.Name = obj.Name; //temp.ParentID = obj.ParentID; temp.Available = obj.Available; temp.Desription = obj.Desription; return(db.SaveChanges()); } }
//public int Delete(string FunctionID) //{ // using (var db = new BCBackContext()) // { // RFAFunction temp = db.RFAFunctions.FirstOrDefault(x => x.FunctionID == FunctionID); // if (null == temp) // return 0; // db.RFAFunctions.Remove(temp); // Action<string> deleteChildren = null; // deleteChildren = (parentId) => // { // List<RFAFunction> list = db.RFAFunctions.Where(x => x.ParentID == FunctionID).ToList<RFAFunction>(); // for (int i = 0; i < list.Count; i++) // { // var tempFunction = list[i]; // db.RFAFunctions.Remove(tempFunction); // deleteChildren(tempFunction.FunctionID); // } // }; // deleteChildren(temp.FunctionID); // return db.SaveChanges(); // } //} public int Add(FunctionDto obj) { using (var db = new BCEnterpriseContext()) { RFAFunction temp = new RFAFunction(); temp.FunctionID = obj.FunctionID; temp.MyID = obj.MyID; temp.Name = obj.Name; temp.ParentID = obj.ParentID; temp.Available = obj.Available; temp.Desription = obj.Desription; db.RFAFunctions.Add(temp); // db.Entry<RFAFunction>(temp).State = EntityState.Added; return(db.SaveChanges()); } }
private bool HaveFuncction(FunctionDto fun, IEnumerable <string> auths) { bool f = false; if (fun == null || auths == null || auths.Count() == 0) { return(f); } var list = auths.Where(m => m == fun.FunctionID); var model = list.FirstOrDefault(); if (model != null) { if (!string.IsNullOrEmpty(model)) { f = true; } } return(f); }
public ActionResult Edit(int ID, string NAME, int MODULE_ID, int STATUS, int IS_NEW, string LINKURL) { var a = (UserDto)Session["Account"]; var HelperBo = new HelperBo(); var statusVal = STATUS == 1 ? true : false; var isNewVal = IS_NEW == 1 ? true : false; var moduleFunction = new FunctionDto() { NAME = NAME, MODULE_ID = MODULE_ID, STATUS = statusVal, IS_NEW = isNewVal, LINKURL = LINKURL }; var res = HelperBo.UpdateWhere(tableName, moduleFunction, "ID=" + ID); return(Content(JsonConvert.SerializeObject(new { isSuccess = res.message }), "application/json")); }
public StandardJsonResult AddFunc(FunctionDto model) { var res = new StandardJsonResult <int>(); res.Try(() => { if (model.MyID == null || model.Name == null || model.ParentID == null) { res.Success = false; res.Message = "传递到服务器的参数不合法"; res.Value = -1; } else { model.MyID = model.MyID.Replace(" ", ""); model.FunctionID = model.ParentID + "." + model.MyID; res.Value = _functionManagementService.Add(model); } }); return(res); }
public IActionResult AddFunction([FromBody] FunctionDto functionDto) { var function = _mapper.Map <Function>(functionDto); //Company company = new Company() //{ // Name = companyDto.Name, // CategoryId = companyDto.CategoryId, // Section = companyDto.Section, // FunctionCode = companyDto.FunctionCode //}; try { _service.Create(function); return(Ok("Records Added Successfully.. ")); } catch (AppException ex) { return(BadRequest(new { message = ex.Message })); } }
public ActionResult Delete(int id) { var helperBo = new HelperBo(); var funcDto = helperBo.SelectWhere(null, tableName, "ID=" + id, null); var res = helperBo.DeleteWhere(tableName, "ID=" + id); var t = new FunctionDto(); if (funcDto != null && funcDto != null) { t.MODULE_ID = funcDto.data[0].MODULE_ID; t.POSITION = funcDto.data[0].POSITION; } if (res.success) { var functionBo = new HelperBo(); var resReorder = functionBo.ReorderFunction(t.POSITION.ToString(), t.MODULE_ID.ToString(), tableName); } return(Content(JsonConvert.SerializeObject(new { isSuccess = true }), "application/json")); }
public async Task <IActionResult> Edit(long?id, long?pid) { if (id.HasValue) { //编辑 var module = await _service.GetByIdAsync(id.Value); if (module == null) { throw new VinoDataNotFoundException("无法取得数据!"); } if (module.ParentId.HasValue) { ViewBag.Parents = await _service.GetParentsAsync(module.ParentId.Value); } ViewData["Mode"] = "Edit"; return(View(module)); } else { //新增 FunctionDto dto = new FunctionDto(); dto.IsEnable = true; if (pid.HasValue) { dto.ParentId = pid.Value; ViewBag.Parents = await _service.GetParentsAsync(pid.Value); } else { dto.ParentId = null; } ViewData["Mode"] = "Add"; return(View(dto)); } }
// // GET: /Group/ public ActionResult ChangeRole(int id) { ViewBag.groupId = id; var listGroupToFunction = new List <GroupToFunctionDataResponse>(); var helperBo = new HelperBo(); var listModule = new List <ModuleDto>(); #region GetListModule var moduleResponse = helperBo.SelectWhere(null, "module", null, null); if (moduleResponse.data != null) { foreach (var item in moduleResponse.data) { var dto = new ModuleDto(); dto.ID = item.Id; dto.Name = item.Name; listModule.Add(dto); } } #endregion #region GetListFunction // list function var listFunction = new List <FunctionDto>(); var functionResponse = helperBo.SelectWhere(null, "modulefunctions", null, null); if (moduleResponse.data != null) { foreach (var item in functionResponse.data) { var dto = new FunctionDto(); dto.ID = item.ID; dto.NAME = item.NAME; dto.IS_NEW = item.IS_NEW == 1?true:false; dto.LINKURL = item.LINKURL; dto.MODULE_ID = item.MODULE_ID; foreach (var module in listModule) { if (module.ID == dto.MODULE_ID) { dto.MODULE_NAME = module.Name; } } dto.POSITION = item.POSITION; dto.STATUS = item.STATUS == 1?true:false; listFunction.Add(dto); } } #endregion #region GetListSelectedGroup2Function var listSelected = helperBo.SelectWhere(null, tableName, "ID_GROUP=" + id, null); #endregion #region FillAllFunctionToTable foreach (var item in listFunction) { var g2fDto = new GroupToFunctionDataResponse(); g2fDto.ID = 0; g2fDto.ID_GROUP = id; g2fDto.ID_FUNCTION = item.ID; g2fDto.ALLOW_VIEW = 0; g2fDto.ALLOW_ADD = 0; g2fDto.ALLOW_EDIT = 0; g2fDto.ALLOW_DEL = 0; g2fDto.ALLOW_EXPORT = 0; g2fDto.FNAME = item.MODULE_NAME + " - " + item.NAME; listGroupToFunction.Add(g2fDto); } #endregion #region UpdateSelectedFunctionToAboveTable if (listSelected != null) { foreach (var item in listSelected.data) { foreach (var gtf in listGroupToFunction) { if (item.ID_GROUP == gtf.ID_GROUP && item.ID_FUNCTION == gtf.ID_FUNCTION) { gtf.ID = item.ID; gtf.ALLOW_VIEW = item.ALLOW_VIEW; gtf.ALLOW_ADD = item.ALLOW_ADD; gtf.ALLOW_EDIT = item.ALLOW_EDIT; gtf.ALLOW_DEL = item.ALLOW_DEL; gtf.ALLOW_EXPORT = item.ALLOW_EXPORT; } } } } #endregion return(View(listGroupToFunction)); }
public ActionResult GetFunclistByJson() { //分页查询所需参数 暂不分页 //int page = fvmodel.page; //int pagesz = fvmodel.rows; //string name = fvmodel.name; //初始化 添加根 if (!_functionManagementService.ExistFunction("Root")) { var Root = new FunctionDto { ParentID = "", Name = "Root", MyID = "", Available = true, Desription = "这是功能表的根,不能编辑", FunctionID = "Root" }; _functionManagementService.Add(Root); } //不分页查询 List <FunctionDto> list = _functionManagementService.GetAllFunctions(); if (!_functionManagementService.ExistFunction("Root")) { throw new ArgumentNullException("add Root fail"); } if (list == null) { throw new ArgumentNullException("func list get from service is null!"); } List <JsonItem> listjson = new List <JsonItem>(); foreach (var fun in list) { var jfun = new JsonItem(); jfun.Available = fun.Available; jfun.Desription = fun.Desription; jfun.FunctionID = fun.FunctionID; jfun.MyID = fun.MyID; jfun.Name = fun.Name; jfun.text = fun.Name; jfun.ParentID = fun.ParentID; jfun.id = _helper.processSID(fun.FunctionID); jfun._parentId = _helper.processSID(fun.ParentID); // if ( fun.FunctionID.Count(chara=>chara.Equals('.') )>=2 ) {jfun.state = "closed"; } listjson.Add(jfun); } int size = listjson.Count(); var result = new JsonResults(); result.total = _functionManagementService.GetAmount(); result.rows = listjson; //var resStr = Serializer.ToJson(result); return(new OringinalJsonResult <JsonResults> { Value = result }); }
public async Task<ActionResult> EditFunctionData(FunctionDto[] dtos) { dtos.CheckNotNull("dtos"); OperationResult result = await SecurityContract.EditFunctions(dtos); return Json(result.ToAjaxResult()); }
public ActionResult Edit(FunctionDto[] dtos) { dtos.CheckNotNull("dtos" ); OperationResult result = SecurityContract.EditFunctions(dtos); return Json(result.ToAjaxResult()); }
public async Task <IActionResult> Save(FunctionDto model) { await _service.SaveAsync(model); return(JsonData(model)); }
private IEnumerable <TreeDataModelBase> FunctionDtoToTreeResultModelBase(IEnumerable <FunctionDto> source, IEnumerable <string> auths, FunctionDto parentModel) { List <TreeDataModelBase> resultlist = new List <TreeDataModelBase>(); if (source != null && source.Count() > 0) { if (parentModel == null) { return(resultlist); } IEnumerable <FunctionDto> sublist = source.Where(m => m.ParentID == parentModel.FunctionID); // var pmodel=sublist.FirstOrDefault(); if (isfirst) { isfirst = false; sublist = source.Where(m => m.ParentID == ""); } foreach (FunctionDto fun in sublist) { resultlist.Add(new TreeDataModelBase() { id = fun.FunctionID, text = fun.Name, state = "open", iconCls = "", @checked = HaveFuncction(fun, auths), children = FunctionDtoToTreeResultModelBase(source, fun) }); } } return(resultlist); }
// // GET: /Menu/ public ActionResult Index() { var tmpRequestRawUrl = Request.RawUrl.Split('/'); var count = 0; foreach (var item in tmpRequestRawUrl) { count++; } var functionName = "Index"; if (count > 2) { functionName = Request.RawUrl.Split('/')[2]; } var controllerName = Request.RawUrl.Split('/')[1]; var list = new List <dynamic>(); var listFunctionAllow = new List <FunctionDto>(); var acc = Session["Account"]; if (acc != null) { #region List allow functions of Current User var a = (UserDto)acc; ViewBag.USER_GROUP_ID = a.GroupId; ViewBag.displaySpecialFunction = false; var helperBo = new HelperBo(); var UserName = a.Username.Trim(); var DateNow = DateTime.Now.ToString("yyyyMMdd"); var key = Common.Md5Hash(UserName + DateNow); ViewBag.Key = key; var groupOfUser = a.GroupId; var listFunctions = new ResponseBase <List <dynamic> >(); if (groupOfUser == "") { } else { listFunctions = helperBo.SelectWhere("*", "group2functions", "ID_GROUP=" + groupOfUser + " AND ALLOW_VIEW=1", null); if (listFunctions.success) { list = listFunctions.data; } } #endregion #region AllModules var listModule = helperBo.SelectWhere("*", "module", null, null); var listModuleObject = new List <ModuleDto>(); foreach (var item in listModule.data) { var dto = new ModuleDto(); dto.ID = item.Id; dto.Icon = item.Icon; dto.Description = item.Description; dto.Name = item.Name; dto.Status = item.Status == 1?true:false; dto.position = item.position; listModuleObject.Add(dto); } #endregion var listChosenModule = new List <ModuleDto>(); foreach (var item1 in list) { var function = helperBo.SelectWhere("*", "modulefunctions", "ID=" + item1.ID_FUNCTION, null); if (function.success && function.data.Count > 0) { var functionDto = new FunctionDto(); var item = function.data; functionDto.ID = item[0].ID; functionDto.IS_NEW = item[0].IS_NEW == 1?true:false; functionDto.LINKURL = item[0].LINKURL; functionDto.MODULE_ID = item[0].MODULE_ID; functionDto.NAME = item[0].NAME; functionDto.POSITION = item[0].POSITION; functionDto.STATUS = item[0].STATUS == 1 ? true : false; foreach (var j in listModuleObject) { if (j.ID == functionDto.MODULE_ID) { functionDto.MODULE_NAME = j.Name; if (!listChosenModule.Exists(x => x.ID == j.ID)) { listChosenModule.Add(j); } } } listFunctionAllow.Add(functionDto); } } ViewBag.ChosenModule = listChosenModule.OrderBy(x => x.position); } // // var isAllowAccessPage = false; var isAllowAccessPage = true; if (listFunctionAllow.Count == 0 && controllerName.Equals("Error", StringComparison.CurrentCultureIgnoreCase)) { isAllowAccessPage = true; } else { foreach (var i in listFunctionAllow) { var t = i.LINKURL.Split('/'); var tcon = t[1]; var tact = t[2]; if (tcon.Equals(controllerName, StringComparison.CurrentCultureIgnoreCase) || controllerName.Equals("Error", StringComparison.CurrentCultureIgnoreCase) || controllerName.Equals("Home", StringComparison.CurrentCultureIgnoreCase) || controllerName.Equals("GroupToFunction", StringComparison.CurrentCultureIgnoreCase) || (controllerName.Equals("RequestForm", StringComparison.CurrentCultureIgnoreCase) && (functionName.Equals("IndexManager", StringComparison.CurrentCultureIgnoreCase) || functionName.Equals("EditManager", StringComparison.CurrentCultureIgnoreCase)))) { isAllowAccessPage = true; } } } ViewBag.ShouldRedirect = "false"; if (!isAllowAccessPage) { ViewBag.ShouldRedirect = "true"; } return(PartialView("_MainMenu", listFunctionAllow.OrderBy(y => y.POSITION).GroupBy(x => x.MODULE_ID))); }