public string AddBusTicket(string from, string to, string busCompany, DateTime dateTime, decimal price) { BusTicket ticket = new BusTicket(from, to, busCompany, dateTime, price); string key = ticket.UniqueKey; string result; if (this.ticketCatalog.ContainsKey(key)) { result = "Duplicated " + ticket.Type.ToString().ToLower(); } else { this.ticketCatalog.Add(key, ticket); string fromToKey = ticket.FromToKey; this.ticketCatalogByFromToKey.Add(fromToKey, ticket); this.ticketCatalogByDateAndTimeKey.Add(ticket.DateAndTime, ticket); result = ticket.Type + " created"; } if (result.Contains("created")) { this.busTicketsCount++; } return result; }
public string DeleteBusTicket(string from, string to, string busCompany, DateTime dateTime) { BusTicket ticket = new BusTicket(from, to, busCompany, dateTime); string result = this.DeleteTicket(ticket); if (result.Contains("deleted")) { this.busTicketsCount--; } return result; }