Ejemplo n.º 1
0
        private async Task InvokeDeleteBeerByIdCommandAsync(IContext context, DeleteBeerByIdCommand command)
        {
            var triggeredEvent = new DeleteBeerByIdEvent(command.Id);

            var(IsSuccess, RowsAffected) = await actorManager.RequestAsync <BeerEventActor, (bool, int)>(triggeredEvent);

            context.Respond((IsSuccess, RowsAffected));
        }
Ejemplo n.º 2
0
        public async Task <ActionResult> DeleteBeerById(long id)
        {
            try
            {
                var command = new DeleteBeerByIdCommand(id);
                var(isSuccess, rowsAffected) = await _actorManager.RequestAsync <BeerCommandActor, (bool, int)>(command);

                if (isSuccess && rowsAffected > 0)
                {
                    return(StatusCode(204));
                }
                else if (isSuccess && rowsAffected == 0)
                {
                    return(StatusCode(404));
                }
                return(StatusCode(500));
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.StackTrace);
                return(StatusCode(500));
            }
        }