public void SaveTransaction(Model.Transaction.TransactionDTO transaction) { if (transaction.CodeTransactionID <= 0) { throw new Exception($"[{nameof(SaveTransaction)}] {nameof(TransactionDTO.CodeTransactionID)} is mandatory"); } if (transaction.TypeTransactionID <= 0) { throw new Exception($"[{nameof(SaveTransaction)}] {nameof(TransactionDTO.TypeTransactionID)} is mandatory"); } var newTransaction = new EntityModel.Transaction() { Amount = transaction.Amount, Date = transaction.Date.ToString(DATE_FORMAT), Description = transaction.Description, CodeTransaction_ID = transaction.CodeTransactionID, TypeTransaction_ID = transaction.TypeTransactionID }; contextDB.Transaction.Add(newTransaction); contextDB.SaveChanges(); transaction.ID = (uint)newTransaction.ID; }
public Model.Transaction.TransactionDTO GetTransaction(uint transactionID) { Model.Transaction.TransactionDTO transaction = (from EntityModel.Transaction t in contextDB.Transaction .AsNoTracking() .Include(x => x.TypeTransaction) .Include(x => x.CodeTransaction) where t.ID == transactionID select t) .SingleOrDefault() .ToTransactionDTO(); return(transaction); }