예제 #1
0
        public async Task <IActionResult> RegisterPurchase([FromBody] JObject objData)
        {
            var result = await Task.Run(() =>
            {
                if (objData == null)
                {
                    return(Ok(new APIResponse()
                    {
                        status = APIStatus.FAIL.ToString(), response = "Request is empty"
                    }));
                }
                try
                {
                    var _purchaseInvoiceHdr    = objData["purchaseHdr"].ToObject <TblPurchaseInvoice>();
                    var _purchaseInvoiceDetail = objData["purchaseDetail"].ToObject <TblPurchaseInvoiceDetail[]>();

                    var result = new PurchasesHelper().AddPurchaseRecords(_purchaseInvoiceHdr, _purchaseInvoiceDetail.ToList());
                    if (result)
                    {
                        return(Ok(new APIResponse()
                        {
                            status = APIStatus.PASS.ToString(), response = _purchaseInvoiceHdr
                        }));
                    }

                    return(Ok(new APIResponse()
                    {
                        status = APIStatus.FAIL.ToString(), response = "Registration failed."
                    }));
                }
                catch (Exception ex)
                {
                    return(Ok(new APIResponse()
                    {
                        status = APIStatus.FAIL.ToString(), response = ex.Message
                    }));
                }
            });

            return(result);
        }
예제 #2
0
        public async Task <IActionResult> GetInvoiceDeatilList(string invoiceNo)
        {
            var result = await Task.Run(() =>
            {
                if (string.IsNullOrEmpty(invoiceNo))
                {
                    return(Ok(new APIResponse()
                    {
                        status = APIStatus.FAIL.ToString(), response = "Request is empty"
                    }));
                }
                try
                {
                    var invoiceMasterList = new PurchasesHelper().GetPurchaseInvoiceDetails(invoiceNo);
                    if (invoiceMasterList.Count > 0)
                    {
                        dynamic expando           = new ExpandoObject();
                        expando.InvoiceDetailList = invoiceMasterList;
                        return(Ok(new APIResponse()
                        {
                            status = APIStatus.PASS.ToString(), response = expando
                        }));
                    }

                    return(Ok(new APIResponse()
                    {
                        status = APIStatus.FAIL.ToString(), response = "No Billing record found."
                    }));
                }
                catch (Exception ex)
                {
                    return(Ok(new APIResponse()
                    {
                        status = APIStatus.FAIL.ToString(), response = ex.Message
                    }));
                }
            });

            return(result);
        }
예제 #3
0
        public async Task <IActionResult> GetInvoiceList([FromBody] SearchCriteria searchCriteria)
        {
            var result = await Task.Run(() =>
            {
                if (searchCriteria == null)
                {
                    return(Ok(new APIResponse()
                    {
                        status = APIStatus.FAIL.ToString(), response = "Request is empty"
                    }));
                }
                try
                {
                    var invoiceMasterList = new PurchasesHelper().GetPurchaseInvoices(searchCriteria);
                    if (invoiceMasterList.Count > 0)
                    {
                        dynamic expando     = new ExpandoObject();
                        expando.InvoiceList = invoiceMasterList;
                        return(Ok(new APIResponse()
                        {
                            status = APIStatus.PASS.ToString(), response = expando
                        }));
                    }

                    return(Ok(new APIResponse()
                    {
                        status = APIStatus.FAIL.ToString(), response = "No Billing record found."
                    }));
                }
                catch (Exception ex)
                {
                    return(Ok(new APIResponse()
                    {
                        status = APIStatus.FAIL.ToString(), response = ex.Message
                    }));
                }
            });

            return(result);
        }