public string PostClientDetail(string clientDetail) { var lines = clientDetail.Split(','); var detail = new tcClientDetail() { ClientId = lines[0], Credit = Convert.ToDecimal(lines[1]), Payment = Convert.ToDecimal(lines[2]), BillId = int.Parse(lines[3]) }; db.tcClientDetails.Add(detail); db.SaveChanges(); return("Done"); }
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); }