public IHttpActionResult GetInvoiceTable(int id) { MVCInvoiceModel invoiceModel = new MVCInvoiceModel(); invoiceModel = db.InvoiceTables.Where(q => q.InvoiceID == id).Select(c => new MVCInvoiceModel { InvoiceID = c.InvoiceID, Invoice_ID = c.Invoice_ID, RefNumber = c.RefNumber, InvoiceDate = c.InvoiceDate, InvoiceDueDate = c.InvoiceDueDate, SubTotal = c.SubTotal, TotalVat6 = c.TotalVat6, TotalVat21 = c.TotalVat21, DiscountAmount = c.DiscountAmount, TotalAmount = c.TotalAmount, CustomerNote = c.CustomerNote, Status = c.Status, UserId = c.UserId, CompanyId = c.CompanyId, ContactId = c.ContactId, Type = c.Type, InvoiceDescription = c.InvoiceDescription }).FirstOrDefault(); if (invoiceModel == null) { return(NotFound()); } return(Ok(invoiceModel)); }
public IHttpActionResult GetId12(int Id) { try { MVCInvoiceModel inoiceTabe = new MVCInvoiceModel(); inoiceTabe.InvoiceID = db.InvoiceTables.Where(I => I.QutationId == Id).FirstOrDefault().InvoiceID; return(Ok(inoiceTabe)); } catch (Exception) { NotFound(); throw; } }
public IHttpActionResult GetInvoiceCount() { MVCInvoiceModel Invoice = new MVCInvoiceModel(); int InvoiceId = db.InvoiceTables.ToList().Count() + 1; Invoice.Invoice_ID = InvoiceId.ToString(); if (InvoiceId == 0) { return(Ok(Invoice)); } else { return(Ok(Invoice)); } }
public JsonResult Proceeds(int Id, string Status) { MvcPurchaseModel PurchaseModel = new MvcPurchaseModel(); List <MvcPurchaseViewModel> _PurcchaseDetailList = new List <MvcPurchaseViewModel>(); InvoiceTable InvoiceTable = new InvoiceTable(); MVCInvoiceModel mvcInvoiceModel = new MVCInvoiceModel(); PurchaseOrderTable purchasemodel = new PurchaseOrderTable(); try { PurchaseModel = GetPurchasae(Id); _PurcchaseDetailList = GetPurchaseDetail(Id); if (PurchaseModel != null) { BillTable billtable = new BillTable(); billtable.CompanyId = PurchaseModel.CompanyId; billtable.UserId = Convert.ToInt32(Session["LoginUserID"]); billtable.Bill_ID = PurchaseModel.PurchaseID.ToString(); billtable.PurchaseId = PurchaseModel.PurchaseOrderID; billtable.VenderId = PurchaseModel.VenderId; billtable.RefNumber = PurchaseModel.PurchaseRefNumber; billtable.BillDate = Convert.ToDateTime(PurchaseModel.PurchaseDate); billtable.BillDueDate = Convert.ToDateTime(PurchaseModel.PurchaseDueDate); billtable.SubTotal = PurchaseModel.PurchaseSubTotal; billtable.DiscountAmount = PurchaseModel.PurchaseTotoalAmount; billtable.TotalAmount = PurchaseModel.PurchaseTotoalAmount; billtable.CustomerNote = PurchaseModel.PurchaseVenderNote; billtable.TotalVat6 = PurchaseModel.Vat6; billtable.TotalVat21 = PurchaseModel.Vat21; billtable.Status = "accepted"; billtable.Type = StatusEnum.Goods.ToString(); // bill Api HttpResponseMessage response = GlobalVeriables.WebApiClient.PostAsJsonAsync("AddBill", billtable).Result; BillTable billviewmodel = response.Content.ReadAsAsync <BillTable>().Result; if (response.StatusCode == System.Net.HttpStatusCode.OK) { if (_PurcchaseDetailList != null) { foreach (var item in _PurcchaseDetailList) { BillDetailTable billdetailtable = new BillDetailTable(); billdetailtable.BillID = billviewmodel.BilID; billdetailtable.ItemId = item.PurchaseItemId; billdetailtable.Description = item.PurchaseDescription; billdetailtable.Quantity = item.PurchaseQuantity; billdetailtable.Rate = item.PurchaseItemRate; billdetailtable.Total = item.PurchaseTotal; billdetailtable.Type = item.Type; billdetailtable.RowSubTotal = Convert.ToDouble(item.RowSubTotal); billdetailtable.Vat = item.PurchaseVatPercentage; billdetailtable.ServiceDate = item.ServiceDate; // APIBill HttpResponseMessage responsses = GlobalVeriables.WebApiClient.PostAsJsonAsync("AddBillDetail", billdetailtable).Result; if (responsses.StatusCode != System.Net.HttpStatusCode.OK) { return(new JsonResult { Data = new { Status = "Fail", Message = "Fail to Proceed" } }); } } if (UpdateQuatationStation(Id)) { return(new JsonResult { Data = new { Status = "Success", Message = "Proceed successfullly" } }); } } } } } catch (Exception) { throw; } return(new JsonResult { Data = new { Status = "Success", Message = "Proceed successfullly" } }); }
public JsonResult Proceeds(int QutationId, string Status, string Type) { HttpResponseMessage responsses = new HttpResponseMessage(); MVCQutationModel QutationModel = new MVCQutationModel(); List <MVCQutationViewModel> _QuatationDetailList = new List <MVCQutationViewModel>(); InvoiceTable InvoiceTable = new InvoiceTable(); MVCInvoiceModel mvcInvoiceModel = new MVCInvoiceModel(); try { QutationModel = GetQutationById(QutationId); _QuatationDetailList = GetQuatationDetailListById(QutationId); if (QutationModel != null) { mvcInvoiceModel.Invoice_ID = QutationModel.Qutation_ID; mvcInvoiceModel.QutationId = QutationModel.QutationID; mvcInvoiceModel.CompanyId = QutationModel.CompanyId; mvcInvoiceModel.UserId = Convert.ToInt32(Session["LoginUserID"]); mvcInvoiceModel.ContactId = QutationModel.ContactId; mvcInvoiceModel.InvoiceID = 0; mvcInvoiceModel.RefNumber = QutationModel.RefNumber; mvcInvoiceModel.InvoiceDate = QutationModel.QutationDate; mvcInvoiceModel.InvoiceDueDate = QutationModel.DueDate; mvcInvoiceModel.SubTotal = QutationModel.SubTotal; mvcInvoiceModel.DiscountAmount = QutationModel.DiscountAmount; mvcInvoiceModel.TotalAmount = QutationModel.TotalAmount; mvcInvoiceModel.CustomerNote = QutationModel.CustomerNote; mvcInvoiceModel.TotalVat21 = QutationModel.TotalVat21; mvcInvoiceModel.TotalVat6 = QutationModel.TotalVat6; mvcInvoiceModel.Type = StatusEnum.Goods.ToString(); mvcInvoiceModel.Status = "accepted"; HttpResponseMessage InvoiceResponse = GlobalVeriables.WebApiClient.PostAsJsonAsync("PostInvoice", mvcInvoiceModel).Result; InvoiceTable = InvoiceResponse.Content.ReadAsAsync <InvoiceTable>().Result; if (InvoiceResponse.StatusCode == System.Net.HttpStatusCode.OK) { if (_QuatationDetailList != null) { foreach (var item in _QuatationDetailList) { InvoiceDetailsTable InvoiceDetails = new InvoiceDetailsTable(); InvoiceDetails.ItemId = Convert.ToInt32(item.ItemId); InvoiceDetails.InvoiceId = InvoiceTable.InvoiceID; InvoiceDetails.Description = item.Description; InvoiceDetails.Quantity = item.Quantity; InvoiceDetails.Rate = Convert.ToDouble(item.Rate); InvoiceDetails.Total = Convert.ToDouble(item.Total); InvoiceDetails.ServiceDate = item.ServiceDate; InvoiceDetails.RowSubTotal = item.RowSubTotal; InvoiceDetails.Vat = Convert.ToDouble(item.Vat); InvoiceDetails.Type = item.Type; responsses = GlobalVeriables.WebApiClient.PostAsJsonAsync("PostinvoiceDetails", InvoiceDetails).Result; if (responsses.StatusCode != System.Net.HttpStatusCode.OK) { return(new JsonResult { Data = new { Status = "Fail", Message = "Fail to Proceed" } }); } } if (UpdateQuatationStation(QutationId)) { if (Transaction(QutationModel, "Add")) { return(new JsonResult { Data = new { Status = "Success", Message = "Proceed successfullly" } }); } } } } else { return(new JsonResult { Data = new { Status = "Fail", Message = "Fail Proceed successfullly" } }); } } } catch (Exception) { throw; } return(new JsonResult { Data = new { Status = "Success", Message = "Proceed successfullly" } }); }