public void GroupOperation(OperationDto operationDto) { Operation operation = _operationRepository.Get(operationDto.Id); operation.PermissionId = operationDto.PermissionId; _operationRepository.Update(operation); }
/// <summary> /// 操作授权验证 /// </summary> /// <param name="context"></param> /// <returns></returns> public static AuthorizeResult CheckAuthorization(AuthorizationFilterContext context) { if (context == null) { return(AuthorizeResult.ChallengeResult()); } #region 操作信息 string controllerName = context.RouteData.Values["controller"].ToString(); string actionName = context.RouteData.Values["action"].ToString(); string methodName = context.HttpContext.Request.Method; OperationDto operation = new OperationDto() { ControllerCode = controllerName, ActionCode = actionName }; #endregion //登陆用户 var loginUser = IdentityManager.GetLoginUser(); if (loginUser == null) { return(AuthorizeResult.ChallengeResult()); } var allowAccess = CheckAuthorization(loginUser, operation); return(allowAccess ? AuthorizeResult.SuccessResult() : AuthorizeResult.ForbidResult()); }
public OperationDto GetById(Guid?userId, int id) { OperationDto operation = null; try { using (var context = Factory.CreateContext(ConnexionString)) { var opRepo = Factory.GetOperationRepository(context); Operation myOp = opRepo.GetById(id); if (myOp != null) { BankAccount ba = ExtractBankAccount(userId, myOp.BankAccountId, context); // une exception est lancée si le bank account n'appartient pas à l'user operation = myOp.ToDto(); } } } catch (DaGetServiceException) { throw; } catch (Exception ex) { throw new DaGetServiceException( String.Format("Erreur lors de la récupération de l'opération d'id {0} par l'utilisateur {0}", id, userId), ex); } return(operation); }
public static OperationDto ConvertToViewModel(this Operation operation) { var vm = new OperationDto { Deleted = operation?.IsDeleted ?? false, Active = operation?.Active ?? false, ActiveFrom = operation?.ActiveFrom ?? DateTime.MinValue, ActiveTo = operation?.ActiveFrom ?? DateTime.MinValue, CreatedBy = operation?.CreatedById ?? "", DeletedBy = operation?.DeletedById ?? "", ModifiedBy = operation?.ModifiedById ?? "", DateCreated = operation?.CreatedDate ?? DateTime.MinValue, DateModified = operation?.ModifiedDate ?? DateTime.MinValue, DateDeleted = operation?.DeletedDate ?? DateTime.MinValue, Description = operation?.Description ?? "", Id = operation?.Id, Name = operation.Name ?? "", UserMayViewCreatedProp = true, UserMayViewDeletedProp = true, UserMayViewLastModifieddProp = true, RowVersion = operation.RowVersion }; return(vm); }
public async Task <IActionResult> Create([FromBody] OperationDto operationDto) { var @event = new OperationCreatedEvent(operationDto.Value, operationDto.OperationType); await _operationService.SendOperation(@event); return(Ok()); }
public async Task <(bool, OperationDto)> TrySetAsync(string id, string ownUserId, string name, OperationState state, string code = null, string reason = null, string projectId = null, string issueId = null, string sprintId = null, string userId = null) { var operation = await GetAsync(id); if (operation is null) { operation = new OperationDto(); } else if (operation.State == OperationState.Completed || operation.State == OperationState.Rejected) { return(false, operation); } operation.Id = id; operation.OwnUserId = ownUserId ?? string.Empty; operation.Name = name; operation.State = state; operation.Code = code ?? string.Empty; operation.Reason = reason ?? string.Empty; operation.ProjectId = projectId ?? string.Empty; operation.IssueId = issueId ?? string.Empty; operation.SprintId = sprintId ?? string.Empty; operation.UserId = userId ?? string.Empty; await _cache.SetStringAsync(GetKey(id), JsonConvert.SerializeObject(operation), new DistributedCacheEntryOptions { SlidingExpiration = TimeSpan.FromSeconds(_options.ExpirySeconds) }); OperationUpdated?.Invoke(this, new OperationUpdatedEventArgs(operation)); return(true, operation); }
private void BtnDeleteOperation_Click(object sender, RoutedEventArgs e) { OperationDto clickedOperation = GetClickedOperation(sender); _operationRepo.Delete(clickedOperation.Id); InitializeTransactions(); }
public async Task <IActionResult> Post([FromBody] OperationDto operationDto) { var model = _mapper.Map <OperationDto, Operation>(operationDto); await _operationRepository.AddAsync(model); return(Ok(model)); }
private OperationDto GetClickedOperation(object sender) { DependencyObject parent = ((Button)sender).Parent; while (!(parent is EditableTransactionControl)) { parent = LogicalTreeHelper.GetParent(parent); } int opId = ((EditableTransactionControl)parent).IdOperation; OperationDto operationDto = _operationRepo.Get(opId); return(operationDto); ////get button parent until we reach the user control (Editable Transaction Control) //DependencyObject ucParent = ((Button)sender).Parent; //while (!(ucParent is UserControl)) //{ // ucParent = LogicalTreeHelper.GetParent(ucParent); //} //// cast to specific type from UserControl //EditableTransactionControl userControl = (EditableTransactionControl)ucParent; ////Get from Db the account with the id of the UserControl //OperationDto operationDto = _operationRepo.Get(userControl.IdOperation); //return operationDto; }
private OperationDto Map(OperationResult operationResult) { OperationDto dto; if (operationResult.Status == OperationStatus.Done) { dto = new OperationDto { Status = operationResult.Status.ToString(), Amount = operationResult.Result.Operation.Amount, BalanceAfterApply = operationResult.Result.BalanceAfterApply, AppliedDate = operationResult.Result.AppliedDate, Description = operationResult.Result.ToString() }; } else { dto = new OperationDto { Status = operationResult.Status.ToString(), Description = operationResult.Comment }; } return(dto); }
private void ValidateOperationWallet(OperationDto operationDto, List <Wallet> userWallets) { if (operationDto.WalletId == 0) { var walletCount = userWallets.Count; if (walletCount == 0) { throw new WalletNotFoundException(ServiceMessages.CreateWalletFirst); } if (walletCount > 1) { throw new WalletNotSpecifiedException(ServiceMessages.SpecifyWallet); } operationDto.WalletId = userWallets.First().WalletId; } else { if (userWallets.All(x => x.WalletId != operationDto.WalletId)) { throw new WalletNotFoundException(String .Format(ServiceMessages.WalletNotFound, operationDto.WalletId)); } } }
private void ValidateOperationDate(OperationDto operationDto) { if (operationDto.OperationDate == default) { operationDto.OperationDate = DateTime.Now; } }
public async Task <bool> UpdateOperation(OperationDto operationDto) { var item = _repoWorker.FindById(operationDto.WorkerID); item.Operation = operationDto.Operation; _repoWorker.Update(item); return(await _repoWorker.SaveAll()); }
public async Task <IActionResult> UpdateOperation(OperationDto update) { if (await _workerService.UpdateOperation(update)) { return(NoContent()); } return(BadRequest($"Updating Worker {update.WorkerID} failed on save")); }
public ActionResult Save(OperationDto model) { var saveState = BusinessHelper.BuildSaveState(Request); _operationBll.HttpPostSave(model, saveState); return(RedirectToAction("Index", "Operation")); }
public async Task <IActionResult> AddAsync([FromBody] OperationDto operation) { var appUser = await userManager.FindByNameAsync(User.Identity.Name); Guid operationId = this.operationService.AddOperation(operation, appUser); return(Ok(operationId)); }
static void PrintOperation(OperationDto operation) { Console.WriteLine($"{nameof(operation.Id)}: {operation.Id}" + $"\t{nameof(operation.CreationDate)}: {operation.CreationDate}" + $"\t{nameof(operation.OperationType)}: {operation.OperationType}" + $"\t{nameof(operation.Values)}: {string.Join(',', operation.Values)}" + $"\t{nameof(operation.Result)}: {operation.Result}"); }
private static int CalculateInternal(OperationDto parameter) { if (parameter is null) { throw new ArgumentNullException(nameof(parameter)); } return(parameter.First - parameter.Second); }
private void CheckIfOperationTypeIsCorrect(OperationDto operation, Dal.Interface.IContext context) { var baOpTyRepo = Factory.GetBankAccountOperationTypeRepository(context); if (!baOpTyRepo.GetAllByBankAccountId(operation.BankAccountId.Value).Any(ot => ot.Id.Equals(operation.BankAccountOperationTypeId))) { throw new DaGetServiceException(String.Format("Type d'opération {0} non autorisé sur ce compte {1}", operation.BankAccountOperationTypeId, operation.BankAccountId)); } }
public bool Update(OperationDto operation) { if (presenter.Update(operation)) { OperationBindingList.ResetBindings(); return(true); } return(false); }
public bool Remove(OperationDto operation) { if (presenter.Remove(operation)) { OperationBindingList.Remove(operation); return(true); } return(false); }
public IActionResult Put([FromBody] OperationDto model) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } return(Ok(_operationService.Update(User.Identity.GetUserId(), model))); }
public bool Insert(OperationDto operation) { if (presenter.Insert(operation) != null) { OperationBindingList.Add(operation); return(true); } return(false); }
public async Task PublishOperationCompletedAsync(OperationDto operation) => await _hubContextWrapper.PublishToUserAsync(operation.UserId, "operation_completed", new { id = operation.Id, name = operation.Name } );
public async Task PublishOperationPendingAsync(OperationDto operation) => await _hubContextWrapper.PublishToUserAsync(operation.UserId, "operation_pending", new { id = operation.Id, name = operation.Name } );
public ResponseDto RemoveOperatin(SecurityResourceDto resource, OperationDto operation) { var result = SecurityResourceServiceAdapter.Execute(s => s.RemoveOperation(resource, operation)); if (result.Response.HasException) { return(null); } return(result); }
private void SetupMocks(Operation createOperation, OperationDto createOperationDto, User user) { MockUnitOfWork.Setup(x => x.UserRepository.GetAsync(It.IsAny <int>())) .ReturnsAsync(user); MockUnitOfWork.Setup(x => x.OperationRepository.Create(It.IsAny <Operation>())); MockUnitOfWork.Setup(x => x.WalletRepository.Update(It.IsAny <Wallet>())); MockUnitOfWork.Setup(x => x.CommitAsync()); MockMapper.Setup(x => x.Map <Operation>(It.IsAny <OperationDto>())).Returns(createOperation); MockMapper.Setup(x => x.Map <OperationDto>(It.IsAny <Operation>())).Returns(createOperationDto); }
private void VerifyMocks(Wallet userWallet, int userId, Operation createOperation, OperationDto createOperationDto, Times methodCalls) { MockUnitOfWork.Verify(x => x.UserRepository.GetAsync(userId)); MockUnitOfWork.Verify(x => x.OperationRepository.Create(createOperation), methodCalls); MockUnitOfWork.Verify(x => x.WalletRepository.Update(userWallet), methodCalls); MockUnitOfWork.Verify(x => x.CommitAsync(), methodCalls); MockMapper.Verify(x => x.Map <Operation>(createOperationDto), methodCalls); MockMapper.Verify(x => x.Map <OperationDto>(createOperation), methodCalls); }
/// <summary> /// 新增 /// </summary> /// <param name="entity"></param> public void Add(OperationDto entity) { using (_unitOfWork) { var info = AutoMapperHelper.Signle <OperationDto, Operation>(entity); var repository = _unitOfWork.Repository <Operation>(); repository.Add(info); _unitOfWork.Commit(); } }
public bool Remove(OperationDto Operation) { ResponseDto response = OperationServiceAdapter.Execute(s => s.Delete(Operation)); if (response.Response.HasException) { return(false); } return(true); }
public OperationViewModel(OperationDto operation) { Operation = operation; }
public OperationViewModel() { Operation = new OperationDto(); }