public async Task <IActionResult> Post([FromBody] Transaction value) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var from = _nominalRepository.Query().Where(i => i.NominalId == value.Id).FirstOrDefault(); if (from == null) { return(BadRequest("Select a Valid Funding Source")); } var to = _nominalRepository.Query().Where(i => i.NominalId == value.NominalId).FirstOrDefault(); if (to == null) { return(BadRequest($"Select a Valid Expense Code Nominal Code")); } value.NominalId = to.NominalId; value.Type = "Debit"; value.Source = "Teller Voucher"; var tell = new Transaction() { TransCode = value.TransCode, Amount = value.Amount, Method = value.Method, Source = "Teller Voucher", Type = "Credit", NominalId = from.NominalId, Reference = value.Reference, UserId = value.UserId, Date = value.Date }; await _transactionRepository.InsertAsync(value); await _transactionRepository.InsertAsync(tell); return(Created($"transaction/{value.TransactionId}", value)); }
public async Task <IActionResult> Get() { var nominal = _nominalRepository.Query(); return(Ok(nominal)); }
public IActionResult Get() { var nominal = _nominalRepository.Query(); return(Ok(nominal)); }