private CreditAccountStateDto CloseAccount(CreditAccountDto account, CreditAccountStateDto latestCreditAccountState) { var accountCurrency = account.Currency; account.IsClosed = true; var updateCreditAccountCommand = new UpdateModelCommand <CreditAccountDto>() { ModelDto = account }; _creditAccountCommandRepository.Execute(updateCreditAccountCommand); var zeroPrice = new PriceDto() { Currency = accountCurrency, Value = 0m }; var closingCreditAccountState = new CreditAccountStateDto() { CreditAccount = account, FinesForOverdue = zeroPrice, InterestCounted = zeroPrice, MainDebtRemain = zeroPrice, RemainDebt = zeroPrice, Month = latestCreditAccountState.Month + 1, TotalInterestSumNotPaid = zeroPrice }; var newCreditAccountStateCommand = new CreateModelCommand <CreditAccountStateDto>() { ModelDto = closingCreditAccountState }; _creditAccountStateCommandRepository.Execute(newCreditAccountStateCommand); return(closingCreditAccountState); }
private void UpdateAccountInternal(int creditAccountId, DateTime specifiedDate) { var newCreditAccountState = UpdateFinesAndGetAccountState(creditAccountId, specifiedDate); var account = _creditAccountQueryRepository.Handle(new ModelQuery() { Id = creditAccountId }); if (account.IsClosed) { return; } if (newCreditAccountState != null) { var createModelCommand = new CreateModelCommand <CreditAccountStateDto>() { ModelDto = newCreditAccountState }; _creditAccountStateCommandRepository.Execute(createModelCommand); if (newCreditAccountState.RemainDebt.Value <= 0) { account.IsClosed = true; var updateModelCommand = new UpdateModelCommand <CreditAccountDto>() { ModelDto = account }; _creditAccountCommandRepository.Execute(updateModelCommand); } } }
public void Handle(CreateModelCommand <HorseModel> command) { var horse = new HorseEntity { Name = command.Model.Name, }; this.horseRepository.Add(horse); }
public void Execute(CreateModelCommand <TModelDto> command) { var model = CreateDbModel(command.ModelDto); RestoreFkModels(model, command.ModelDto); ModelsDao.Add(model); Save(); Mapper.Map(model, command.ModelDto); }
public async Task ExecuteAsync(CreateModelCommand <TModelDto> command) { var model = CreateDbModel(command.ModelDto); RestoreFkModels(model, command.ModelDto); ModelsDao.Add(model); await SaveAsync(); Mapper.Map(model, command.ModelDto); }
public virtual async Task <CommandResult> CreateModelAsync(TModelView viewModel) { var command = new CreateModelCommand <TModelDto> { ModelDto = Mapper.Map <TModelDto>(viewModel) }; var res = await ExecuteCommandAsync(_commandRepository, command); Mapper.Map(command.ModelDto, viewModel); return(res); }
public virtual CommandResult CreateModel(TModelView viewModel) { var command = new CreateModelCommand <TModelDto> { ModelDto = Mapper.Map <TModelDto>(viewModel) }; var res = ExecuteCommand(_commandRepository, command); Mapper.Map(command.ModelDto, viewModel); return(res); }
public void Handle(CreateModelCommand <Location> command) { var location = new LocationModel { Name = command.Model.Name, Address = command.Model.Address, City = command.Model.City, }; _locationRepository.Add(location); }
public void Handle(CreateModelCommand <CustomerModel> command) { var newUser = from user in this.userRepository.Entities where user.Email == command.Model.Email where !user.EmailConfirmed select user; var customer = newUser.Single().CreateNewCustomer(); command.Model.Map(customer); this.customerRepository.Add(customer); }
public async Task <JsonResult> Create([FromBody] DynamicObjectDTO dynamicObjectDTO) { var command = new CreateModelCommand(); command.DynamicObjectDTO = dynamicObjectDTO; bool result = await Mediator.Send(command); if (result) { var controllerCommand = new CreateControllerCommand(); controllerCommand.DynamicObjectDTO = dynamicObjectDTO; result = await Mediator.Send(controllerCommand); if (result) { var viewCommand = new CreateViewCommand(); viewCommand.DynamicObjectDTO = dynamicObjectDTO; result = await Mediator.Send(viewCommand); } } return(Json(dynamicObjectDTO)); }
private void UpdateAccountsInternal(DateTime specifiedDate) { var query = new AllModelsQuery(); var accounts = _creditAccountQueryRepository.Handle(query).Where(a => !a.IsClosed); var creditAccountsStates = new List <CreditAccountStateDto>(); foreach (var account in accounts) { var newCreditAccountState = UpdateFinesAndGetAccountState(account.Id, specifiedDate); if (newCreditAccountState != null) { creditAccountsStates.Add(newCreditAccountState); } } foreach (var state in creditAccountsStates.ToList()) { var createModelCommand = new CreateModelCommand <CreditAccountStateDto>() { ModelDto = state }; _creditAccountStateCommandRepository.Execute(createModelCommand); } }
public void Handle(CreateModelCommand <UserModel> command) { var user = UserEntity.CreateNewUser(command.Model.Email); this.userRepository.Add(user); }
public async Task <ActionResult <int> > Create(CreateModelCommand command) => await Mediator.Send(command);