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 }); }
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 }); }
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 }); }
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 }); }