public async Task <ApiResponse <object> > Create(CreateWeaponDto request) { var command = new CreateWeaponCommand { Name = request.Name, Damage = request.Damage }; await _operationMediator.HandleAsync(command); var location = Url.Link(GetByIdRouteName, new { id = command.GeneratedId }); return(ApiResponse.Created(location, command.GeneratedId)); }
public async Task <Weapon> Handle(CreateWeaponCommand command) { var weapon = new Weapon( command.Name, command.Strength, command.Magic, command.RangeType ); if (weapon.Invalid) { notificationContext.AddNotifications(weapon.ValidationResult); return(null); } this.mongoRepository.Add(weapon); await this.repository.AddAsync(weapon); return(weapon); }
public async Task <IActionResult> PostWeapon(CreateWeaponCommand createWeaponCommand) { var response = await this.createWeaponHandler.Handle(createWeaponCommand); return(Ok(response)); }