private async Task <bool> UpdateAsync(NavNodeDto dto) { bool result = false; var _appEventResult = "Fail"; string _transData = $"ERROR! Not Update Image Signature {dto.Name} by user: {User.Identity.Name}."; try { result = await _navNodeService.UpdateAsync(dto); if (result) { _transData = $"SUCCESSFUL! Update Image Signature {dto.Name} by user: {User.Identity.Name}; "; _appEventResult = "Success"; } } catch (Exception ex) { } #region Log //Insert to log //this.LogSystem(new SystemLogInsertModel //{ // Module = AppModule.SignatureManagement, // Action = AppAction.Update, // Description = _transData, // EventResult = _appEventResult //}); #endregion return(result); }
private async Task <Dictionary <bool, string> > InsertAsync(NavNodeDto dto) { var resultDict = new Dictionary <bool, string>() { [false] = "Tạo mới không thành công. Vui lòng thử lại" }; var _appEventResult = "Fail"; string _transData = $"ERROR! Not Add Signature {dto.Name} by user: {User.Identity.Name}."; try { var result = await _navNodeService.AddAsync(dto); if (result) { resultDict = new Dictionary <bool, string> { [true] = string.Empty }; _transData = $"SUCCESSFUL! ADD Signature {dto.Name} by user: {User.Identity.Name}; "; _appEventResult = "Success"; } } catch (Exception ex) { } #region Log //Insert to log //this.LogSystem(new SystemLogInsertModel //{ // Module = AppModule.SignatureManagement, // Action = AppAction.Insert, // Description = _transData, // EventResult = _appEventResult //}); #endregion return(resultDict); }
public async Task <JsonResult> Insert(NavNodeDto dto) { try { bool result = false; string mesage = string.Empty; if (ModelState.IsValid) { //var dto = _mapper.Map<NavNodeDto>(model); dto.Status = CommonValues.NavNode.NavNodeStatus.Public; dto.CreatedBy = User.Identity.Name; dto.ModifiedBy = User.Identity.Name; var resultDict = await InsertAsync(dto); if (resultDict.ContainsKey(true)) { result = true; } else { mesage = (" " + resultDict.Select(x => x.Value).FirstOrDefault()); } } return(Json(new { status = result, msg = mesage }, JsonRequestBehavior.AllowGet)); } catch (Exception ex) { return(Json(new { status = false, msg = "" }, JsonRequestBehavior.AllowGet)); } }
public void Update(NavNodeDto dto) { StringBuilder _display = new StringBuilder(); if (!string.IsNullOrEmpty(dto.Areas)) { _display.Append(string.Concat("/", dto.Areas)); } if (!string.IsNullOrEmpty(dto.Controller)) { _display.Append(string.Concat("/", dto.Controller)); } if (!string.IsNullOrEmpty(dto.Action)) { _display.Append(string.Concat("/", dto.Action)); } if (!string.IsNullOrEmpty(dto.Params)) { _display.Append(string.Concat("?", dto.Params)); } var _fullName = string.Concat(dto.Name, " ", _display.ToString()); Name = dto.Name; NameEN = dto.Name; Areas = dto.Areas; Controller = dto.Controller; Action = dto.Action; Params = dto.Params; URL = CommonUtility.ToUnsignString(_fullName); ModifiedBy = dto.ModifiedBy; ModifiedDate = DateTime.Now; }
public async Task <bool> AddAsync(NavNodeDto dto) { try { using (var dbContext = _dbContextScopeFactory.Create()) { var entity = NavNode.Create(dto); _navNodeRepository.Add(entity); await dbContext.SaveChangesAsync(); return(true); } } catch (Exception ex) { } return(false); }
/// <summary> /// Tạo mới POCO theo Dto /// </summary> /// <param name="dto"></param> /// <returns></returns> public static NavNode Create(NavNodeDto dto) { StringBuilder _display = new StringBuilder(); if (!string.IsNullOrEmpty(dto.Areas)) { _display.Append(string.Concat("/", dto.Areas)); } if (!string.IsNullOrEmpty(dto.Controller)) { _display.Append(string.Concat("/", dto.Controller)); } if (!string.IsNullOrEmpty(dto.Action)) { _display.Append(string.Concat("/", dto.Action)); } if (!string.IsNullOrEmpty(dto.Params)) { _display.Append(string.Concat("?", dto.Params)); } var _fullName = string.Concat(dto.Name, " ", _display.ToString()); dto.URL = CommonUtility.ToUnsignString(_fullName); return(new NavNode() { Id = Guid.NewGuid(), Name = dto.Name, NameEN = dto.Name, Areas = dto.Areas, Controller = dto.Controller, Action = dto.Action, Params = dto.Params, ResourceId = dto.ResourceId, URL = dto.URL, Description = dto.Description, CreatedBy = dto.CreatedBy, ModifiedBy = dto.ModifiedBy, CreatedDate = DateTime.Now, ModifiedDate = DateTime.Now, Method = dto.Method, ActiveFag = dto.ActiveFag, Status = dto.Status }); }
public async Task <bool> UpdateAsync(NavNodeDto dto) { try { using (var dbContext = _dbContextScopeFactory.Create()) { var entity = await _navNodeRepository.FindAsync(p => p.Id == dto.Id); if (entity != null) { entity.Update(dto); _navNodeRepository.Modify(entity); await dbContext.SaveChangesAsync(); return(true); } } } catch (Exception ex) { } return(false); }