public ActionResult <AccountLedgerDTO> Put([FromBody] AccountLedgerDTO accountLedgerDto) { try { if (!ModelState.IsValid) { _logger.LogError("Invalid model state."); return(BadRequest()); } else { var accountLedger = _mapper.Map <AccountLedger>(accountLedgerDto); _accountLedgerRepo.UpdateAccountLedger(accountLedger); _accountLedgerRepo.Save(); return(Ok(accountLedgerDto)); } } catch (Exception e) { _logger.LogError("Exception occurred while attempting to update an Account.\nError: " + e.Message); return(BadRequest()); } }
public ActionResult <AccountLedgerDTO> Post([FromBody] AccountLedgerDTO accountLedgerDto) { try { if (!ModelState.IsValid) { _logger.LogError("Invalid model state."); return(BadRequest()); } else { var accountLedger = _mapper.Map <AccountLedger>(accountLedgerDto); _accountLedgerRepo.AddAccountLedger(accountLedger); _accountLedgerRepo.Save(); return(Created($"/api/AccountLedgers/{accountLedger.FiscalYearId}-{accountLedger.AccountId}-{accountLedger.LedgerNo}", accountLedgerDto)); } } catch (Exception e) { _logger.LogError("Exception occurred while attempting to add an Account Ledger.\nError: " + e.Message); return(BadRequest()); } }