public async Task <DtoCarta> Handle(CreateCartaCommand request, CancellationToken cancellationToken)
        {
            Carta carta;

            Context.Carta.Add(carta = new Carta {
                Valor = request.Valor
            });
            await SaveChangesAsync();

            return(AutoMapperHelper.MapDto <Carta, DtoCarta>(carta));
        }
        public async Task <DtoHistorial> Handle(CreateHistorialCommand request, CancellationToken cancellationToken)
        {
            Historial historial;

            Context.Historial.Add(historial = new Historial {
                Descripcion = request.Descripcion
            });
            await SaveChangesAsync();

            return(AutoMapperHelper.MapDto <Historial, DtoHistorial>(historial));
        }
Example #3
0
        public async Task <DtoUsuario> Handle(CreateUsuarioCommand request, CancellationToken cancellationToken)
        {
            Usuario usuario;

            Context.Usuario.Add(usuario = new Usuario {
                Nombre = request.Nombre
            });
            await SaveChangesAsync();

            return(AutoMapperHelper.MapDto <Usuario, DtoUsuario>(usuario));
        }
        public async Task <DtoVoto> Handle(CreateVotoCommand request, CancellationToken cancellationToken)
        {
            var carta     = Context.Carta.Any(c => c.Id == request.CartaId);
            var historial = Context.Historial.Any(c => c.Id == request.CartaId);
            var usuario   = Context.Usuario.Any(c => c.Id == request.CartaId);

            if (!(carta && historial && usuario))
            {
                return(null);
            }
            Voto voto;

            Context.Voto.Add(voto = new Voto {
                CartaId = request.CartaId, HistorialId = request.HistorialId, UsuarioId = request.UsuarioId
            });
            await SaveChangesAsync();

            return(AutoMapperHelper.MapDto <Voto, DtoVoto>(voto));
        }
 public async Task <DtoVoto> Handle(GetVotoQuery request, CancellationToken cancellationToken)
 {
     return(await Task.FromResult(AutoMapperHelper.MapDto <Voto, DtoVoto>(Context.Voto.FirstOrDefault(c => c.Id == request.Id))).ConfigureAwait(false));
 }
 public async Task <DtoHistorial> Handle(GetHistorialQuery request, CancellationToken cancellationToken)
 {
     return(await Task.FromResult(AutoMapperHelper.MapDto <Historial, DtoHistorial>(Context.Historial.FirstOrDefault(c => c.Id == request.Id))).ConfigureAwait(false));
 }