Esempio n. 1
0
        public string PostSaleService(string sale)
        {
            var billId = NewBill();
            var lines  = sale.Split('!');

            foreach (var item in lines)
            {
                var fields = item.Split(',');
                var sl     = new tcServiceSale()
                {
                    ServiceId = int.Parse(fields[0]),
                    Quantity  = int.Parse(fields[1]),
                    Price     = Convert.ToDecimal(fields[2]),
                    BillId    = billId,
                };
                db.tcServiceSales.Add(sl);
            }
            db.SaveChanges();
            return(billId.ToString());
        }
Esempio n. 2
0
        public tcBill GetBillDetails(int id)
        {
            var bill = db.tcBills.Find(id);

            var products = new List <tcProductSale>();

            foreach (var item in bill.tcProductSales)
            {
                var p = new tcProductSale()
                {
                    Id = item.Id, BillId = item.Id, Price = item.Price, ProductId = item.ProductId, Quantity = item.Quantity, tcProduct = new tcProduct()
                    {
                        Name = item.tcProduct.Name
                    }
                };
                products.Add(p);
            }

            var services = new List <tcServiceSale>();

            foreach (var item in bill.tcServiceSales)
            {
                var s = new tcServiceSale()
                {
                    Id = item.Id, BillId = item.BillId, Price = item.Price, Quantity = item.Quantity, ServiceId = item.ServiceId, tcService = new tcService()
                    {
                        Name = item.tcService.Name
                    }
                };
                services.Add(s);
            }

            var payments = new List <tcClientDetail>();

            foreach (var item in bill.tcClientDetails)
            {
                var p = new tcClientDetail()
                {
                    BillId        = item.BillId,
                    ClientId      = item.ClientId,
                    Id            = item.Id,
                    Credit        = item.Credit,
                    Payment       = item.Payment,
                    PaymentMethod = item.PaymentMethod
                };
                payments.Add(p);
            }

            var result = new tcBill()
            {
                Id       = bill.Id,
                ClientId = bill.ClientId,
                tcClient = new tcClient()
                {
                    Id = bill.ClientId, Name = bill.tcClient.Name, Group = bill.tcClient.Group
                },
                IsCredit        = bill.IsCredit,
                PaymentMethod   = bill.PaymentMethod,
                User            = bill.User,
                tcProductSales  = products,
                tcServiceSales  = services,
                tcClientDetails = payments
            };

            return(result);
        }