Exemplo n.º 1
0
        public async Task <ICommandResponse> HandleAsync(CreateCategoryCommand command)
        {
            await _context.Categories.AddAsync(command.Category);

            await _context.SaveChangesAsync();

            return(new CommandResponse <int>(command.Category.Id)
            {
                Successful = true
            });
        }
Exemplo n.º 2
0
        public async Task <ICommandResponse> HandleAsync(CreateTransactionCommand command)
        {
            await _context.Transactions.AddAsync(command.Transaction);

            await _context.SaveChangesAsync();

            return(new CommandResponse <int>(command.Transaction.Id)
            {
                Successful = true
            });
        }
Exemplo n.º 3
0
        public async Task <ICommandResponse> HandleAsync(UpdateCategoryCommand command)
        {
            var category = await _context.Categories.SingleOrDefaultAsync(c => c.Id == command.CategoryId);

            category.Description = command.Category.Description;
            category.Active      = command.Category.Active;
            category.Name        = command.Category.Name;

            await _context.SaveChangesAsync();

            return(new CommandResponse <Data.Entity.Category>(command.Category)
            {
                Successful = true
            });
        }
Exemplo n.º 4
0
        public async Task <ICommandResponse> HandleAsync(UpdateTransactionCommand command)
        {
            var transaction = await _context.Transactions.SingleOrDefaultAsync(p => p.Id == command.TransactionId);

            transaction.Description = command.Transaction.Description;
            transaction.CategoryId  = command.Transaction.CategoryId;
            transaction.Credit      = command.Transaction.Credit;
            transaction.Debit       = command.Transaction.Debit;
            transaction.Recorded    = command.Transaction.Recorded;

            await _context.SaveChangesAsync();

            return(new CommandResponse <Data.Entity.Transaction>(command.Transaction)
            {
                Successful = true
            });
        }