Beispiel #1
0
        public async Task <IActionResult> UpdateAgeUser(Guid id, UserUpdateAgeCommand command)
        {
            var entity = await UserRepository.GetUser(id);

            if (entity != null)
            {
                var validationResult = entity.UpdateAge(command);
                if (validationResult.Ok)
                {
                    var hookResult = await EventStore.AppendAll(validationResult.DomainEvents);

                    if (hookResult.Ok)
                    {
                        await UserRepository.UpdateUser(entity);

                        return(new OkResult());
                    }
                    return(new BadRequestObjectResult(hookResult.Errors));
                }
                return(new BadRequestObjectResult(validationResult.DomainErrors));
            }
            return(new NotFoundObjectResult(new List <string> {
                $"Could not find Root User with ID: {id}"
            }));
        }
Beispiel #2
0
 public async Task <IActionResult> UpdateAge(Guid id, [FromBody] UserUpdateAgeCommand command)
 {
     return(await Handler.UpdateAgeUser(id, command));
 }