public async Task <IActionResult> Add([FromBody] LedgerModel newLedgerModel) { ServiceResponseModel <LedgerModel> response = new ServiceResponseModel <LedgerModel>(); try { if (string.IsNullOrWhiteSpace(newLedgerModel.CompCode)) { throw new ArgumentNullException("CompCode is required"); } if (string.IsNullOrWhiteSpace(newLedgerModel.AccYear)) { throw new ArgumentNullException("AccYear is required"); } if (string.IsNullOrWhiteSpace(newLedgerModel.VouNo)) { throw new ArgumentNullException("VouNo is required"); } if (newLedgerModel.ItemSr < 0) { throw new ArgumentNullException("ItemSr is required"); } response = await _ledgerService.Add(newLedgerModel); if (response.Data == null) { return(NotFound(response)); } } catch (Exception ex) { _logger.LogError(ex.StackTrace); response.Success = false; response.Message = ex.Message; } return(Ok(response)); }