Beispiel #1
0
        public async Task <IActionResult> PutWeapon(
            [FromRoute] Guid id,
            [FromBody] UpdateWeaponCommand updateWeaponCommand)
        {
            var response = await this.updateWeaponHandler.Handle(id, updateWeaponCommand);

            return(Ok(response));
        }
Beispiel #2
0
        public async Task <ApiResponse> Update(Guid id, UpdateWeaponDto request)
        {
            var command = new UpdateWeaponCommand
            {
                Id     = id,
                Name   = request.Name,
                Damage = request.Damage
            };
            await _operationMediator.HandleAsync(command);

            return(ApiResponse.Ok());
        }
Beispiel #3
0
        public async Task <Weapon> Handle(Guid id, UpdateWeaponCommand command)
        {
            var originalWeapon = await this.repository.GetByIdAsync(id);

            if (originalWeapon == null)
            {
                notification.AddNotification(id.ToString(), "Non Existe");
                return(null);
            }
            originalWeapon.UpdateWeapon(command.Name, command.Magic, command.Strength, command.RangeType);
            if (originalWeapon.Invalid)
            {
                notification.AddNotifications(originalWeapon.ValidationResult);
                return(null);
            }


            await this.repository.UpdateAsync(originalWeapon);

            return(originalWeapon);
        }