Esempio n. 1
0
        public void InsertBillData(VoygerBillWithLinq voygerBill)
        {
            VoyBill             bill         = voygerBill.bill;
            List <LineItems>    lineItemList = voygerBill.lineItems;
            List <VPaymentMode> paymentList  = voygerBill.payModes;

            ConnectLinqDataBase();
            var v = from vyb in voyDatabase.VoyBill
                    where vyb.BillNumber == bill.BillNumber && vyb.BillTime == bill.BillTime
                    select new { vyb.ID };

            if (v.Count() > 0)
            {
                Console.WriteLine("Invoice all ready Present in file");
                return;
            }
            voyDatabase.VoyBill.InsertOnSubmit(bill);
            voyDatabase.SubmitChanges();
            foreach (LineItems item in lineItemList)
            {
                item.VoyBillId = bill.ID;
                voyDatabase.LineItems.InsertOnSubmit(item);
            }
            foreach (VPaymentMode item in paymentList)
            {
                item.VoyBillId = bill.ID;
                voyDatabase.VPaymentMode.InsertOnSubmit(item);
            }
            InsertDataLog dataLog = new InsertDataLog()
            {
                BillNumber = bill.BillNumber,
                Remark     = "First Step",
                VoyBillId  = bill.ID,
            };

            voyDatabase.InsertDataLogs.InsertOnSubmit(dataLog);
            voyDatabase.SubmitChanges();
        }
Esempio n. 2
0
        private async Task <Uri> AddBill(VoyagerBillInfo bill)
        {
            HttpResponseMessage response = await client.PostAsJsonAsync("api/VoyagerBills", bill);

            LogEvent.WriteEvent("Header:" + response.Headers.ToString());
            LogEvent.WriteEvent("Content:" + response.Content.ToString());
            LogEvent.WriteEvent("Status Code:" + response.StatusCode.ToString());

            response.EnsureSuccessStatusCode();

            if (response.IsSuccessStatusCode)
            {
                LogEvent.WriteEvent("Invocie is saved: " + bill.InvoiceNo);
                using (VoyagerContext db = new VoyagerContext())
                {
                    InsertDataLog log = db.InsertDataLogs.Where(c => c.BillNumber == bill.InvoiceNo).FirstOrDefault();
                    log.Remark          = response.Content.ToString();
                    db.Entry(log).State = System.Data.Entity.EntityState.Modified;
                    db.SaveChanges();
                }
            }
            return(response.Headers.Location);
        }
Esempio n. 3
0
        public void InsertBillData(VoygerBill voygerBill)
        {
            if (voygerBill != null)
            {
                if (voygerBill.bill.BillType != null)
                {
                    LogEvent.WriteEvent("bill tye: " + voygerBill.bill.BillType);
                }
            }
            VoyBill bill = voygerBill.bill;

            List <LineItem>     lineItemList = voygerBill.lineItems;
            List <VPaymentMode> paymentList  = voygerBill.payModes;

            VoyagerContext voyDatabase;

            using (voyDatabase = new VoyagerContext())
            {
                // TODO:Need to Check line below here
                var v = from vyb in voyDatabase.VoyBills
                        where vyb.BillNumber == bill.BillNumber && vyb.BillTime == bill.BillTime
                        select new { vyb.VoyBillId };

                if (v.Count() > 0)
                {
                    LogEvent.WriteEvent($"Invoice all ready Present in file {v.FirstOrDefault().VoyBillId},{bill.BillNumber}");
                    return;
                }
                else
                {
                    LogEvent.WriteEvent($"Invoice is new with bill no {bill.BillNumber}");
                }

                voyDatabase.VoyBills.Add(bill);
                if (voyDatabase.SaveChanges() > 0)
                {
                    LogEvent.WriteEvent($"Bill with ID: {bill.VoyBillId} is saved!!! ");
                }
                else
                {
                    LogEvent.WriteEvent("bill is not Saved");
                }
                foreach (LineItem item in lineItemList)
                {
                    item.VoyBillId = bill.VoyBillId;
                    voyDatabase.LineItems.Add(item);
                }
                //   LogEvent.WriteEvent("Inserted LinesItem");
                foreach (VPaymentMode item in paymentList)
                {
                    item.VoyBillId = bill.VoyBillId;
                    voyDatabase.VPaymentModes.Add(item);
                }
                //  LogEvent.WriteEvent("Inserted payments");
                InsertDataLog dataLog = new InsertDataLog()
                {
                    BillNumber = bill.BillNumber,
                    Remark     = "First Step",
                    VoyBillId  = bill.VoyBillId,
                };
                LogEvent.WriteEvent("Inserted Datalog,payments,LinesItem,payments");
                voyDatabase.InsertDataLogs.Add(dataLog);

                voyDatabase.SaveChanges();
                LogEvent.WriteEvent("VoyBill is added with BillId: [" + bill.VoyBillId + "]and BillNo: [" + bill.BillNumber + "]");
            }
        }
 partial void DeleteInsertDataLog(InsertDataLog instance);
 partial void UpdateInsertDataLog(InsertDataLog instance);
 partial void InsertInsertDataLog(InsertDataLog instance);