public static CloseTicket Close() { var document = XDocument.Load(PathCheck); var closeTicket = CloseTicket.FromCheckXElement(document.GetXElement("checks")); closeTicket.DateClose = DateTime.Now; document.GetXAttribute("checks", "closeDate").SetValue(closeTicket.DateClose.ToString(Config.DateFormat)); File.WriteAllText(PathCheck, document.ToString()); var payProducts = new List <PayProduct>(); var closeTicketCheckDiscounts = new List <CloseTicketCheckDiscount>(); foreach (var check in closeTicket.ChecksTicket) { payProducts.AddRange(check.PayProducts); if (check.CheckDiscount != null) { closeTicketCheckDiscounts.Add(check.CheckDiscount); } } Add(closeTicket); RepositoryCheckTicket.AddRange(closeTicket.ChecksTicket); RepositoryPayProduct.AddRange(payProducts); RepositoryCloseTicketCheckDiscount.AddRange(closeTicketCheckDiscounts); return(closeTicket); }
public static List <CheckTicket> GetByCloseTicketId(Guid customerId) { if (CheckTickets.Count == 0) { Sync(); } var checkTickets = CheckTickets.FindAll(c => c.CloseTicketCustomerId == customerId); if (RepositoryCloseTicketCheckDiscount.CloseTicketCheckDiscounts.Count == 0) { RepositoryCloseTicketCheckDiscount.Sync(); } foreach (var checkTicket in checkTickets) { checkTicket.CheckDiscount = RepositoryCloseTicketCheckDiscount.Get(checkTicket.CustomerId); } return(checkTickets); }