Exemplo n.º 1
0
        public async Task <IActionResult> SaleRegister([FromBody] ReportModel reportModel)
        {
            ServiceResponseModel <SalePurchaseReportModel> response = new ServiceResponseModel <SalePurchaseReportModel>();

            try
            {
                if (string.IsNullOrWhiteSpace(reportModel.CompCode))
                {
                    throw new ArgumentNullException("CompCode is required");
                }
                if (string.IsNullOrWhiteSpace(reportModel.AccYear))
                {
                    throw new ArgumentNullException("AccYear is required");
                }
                if (reportModel.FinishDate.CompareTo(reportModel.StartDate) < 0)
                {
                    throw new ArgumentNullException("Invalid StartDate Or Finish date");
                }
                if (string.IsNullOrWhiteSpace(reportModel.SaleOrPurchaseType) || (reportModel.SaleOrPurchaseType != "S" && reportModel.SaleOrPurchaseType != "P"))
                {
                    throw new ArgumentNullException("SaleOrPurchaseType is required and value should be S or P");
                }
                response = await _ledgerService.SaleRegister(reportModel);

                if (response.Data == null)
                {
                    return(NotFound(response));
                }
            }
            catch (Exception ex)
            {
                _logger.LogError(ex.StackTrace);
                response.Success = false;
                response.Message = ex.Message;
            }
            return(Ok(response));
        }