public async Task <IActionResult> Delete(string userId, ApproverConfigType type) { var result = await _aproverConfigService.Delete(CurrentUser.TenantId, userId, type); if (result.Code < 0) { return(BadRequest(result)); } return(Ok(result)); }
public async Task <int> ForceDelete(string userId, ApproverConfigType type) { var approverconfigInfo = await GetInfo(userId, type); if (approverconfigInfo == null) { return(-1); } _approverConfigRepository.Delete(approverconfigInfo); return(await Context.SaveChangesAsync()); }
public async Task <ActionResultResponse> Insert(string tenantId, string userId, ApproverConfigType type) { var isApproveConfigExists = await _approverConfigRepository.CheckExistsUserId(tenantId, userId, type); if (isApproveConfigExists) { return(new ActionResultResponse(-1, _resourceService.GetString("Approver already exists."))); } var userInfo = await _userAccountRepository.GetInfo(userId); if (userInfo == null) { return(new ActionResultResponse(-2, _resourceService.GetString("Approver info does not exists."))); } var result = await _approverConfigRepository.Insert(new ApproverConfig { TenantId = tenantId, UserId = userInfo.Id, FullName = userInfo.FullName, UnsignName = userInfo.FullName.Trim().StripVietnameseChars().ToUpper(), Avatar = userInfo.Avatar, Type = type, UserName = userInfo.UserName }); if (result > 0) { return(new ActionResultResponse(result, _resourceService.GetString("Add new ApproverConfig successful."))); } await RollbackInsert(); return(new ActionResultResponse(-3, _resourceService.GetString(ErrorMessage.SomethingWentWrong))); async Task RollbackInsert() { await _approverConfigRepository.ForceDelete(userId, type); } }
public async Task <bool> CheckExistsUserId(string tenantId, string userId, ApproverConfigType type) { return(await _approverConfigRepository.CheckExistsUserId(tenantId, userId, type)); }
public async Task <ActionResultResponse> Delete(string tenantId, string userId, ApproverConfigType type) { var approverConfigInfo = await _approverConfigRepository.GetInfo(userId, type); if (approverConfigInfo == null) { return(new ActionResultResponse(-1, _sharedResourceService.GetString("Approver does not exists."))); } if (approverConfigInfo.TenantId != tenantId) { return(new ActionResultResponse(-2, _sharedResourceService.GetString(ErrorMessage.NotHavePermission))); } var result = await _approverConfigRepository.ForceDelete(userId, type); return(new ActionResultResponse(result, result <= 0 ? _sharedResourceService.GetString(ErrorMessage.SomethingWentWrong) : _resourceService.GetString("Delete Approver successful."))); }
public async Task <ApproverConfig> GetInfo(string userId, ApproverConfigType type) { return(await _approverConfigRepository.GetAsync(false, x => x.UserId == userId && x.Type == type)); }
public async Task <bool> CheckExistsUserId(string tenantId, string userId, ApproverConfigType type) { return(await _approverConfigRepository.ExistAsync(x => x.TenantId == tenantId && x.UserId == userId && x.Type == type)); }
//[CheckPermission(PageId.ApproverConfig, Permission.Delete)] public async Task <IActionResult> CheckExistsUserId(string tenantId, string userId, ApproverConfigType type) { var result = await _aproverConfigService.CheckExistsUserId(tenantId, userId, type); return(Ok(result)); }