/// <summary> /// Get latest tickets. /// </summary> /// <param name="account">The account for which to get the tickets</param> /// <param name="limit">The max number of thickets to fetch</param> /// <returns></returns> public IEnumerable<TicketWebServiceModel> GetHistoryWithLimit(AccountWebServiceModel account, int limit) { var dmAccount = new Account() { GUID = account.GUID }; return ticketService.GetHistory(dmAccount, limit) .Select(t => TicketWebServiceModel.FromDataModel(t, account)) .ToList(); }
public static TicketWebServiceModel FromDataModel(Ticket ticket, AccountWebServiceModel accountWebServiceModel) { if (ticket == null) return null; return new TicketWebServiceModel { Account = accountWebServiceModel, Created = ticket.Created, GUID = ticket.GUID, Bus = BusWebServiceModel.FromDataModel(ticket.Bus) }; }
/// <summary> /// Buy a new subscription for all the lines /// </summary> /// <param name="account">The account for which to buy the subscription</param> /// <param name="startDate">The start date for the new subscription</param> /// <returns></returns> public SubscriptionWebServiceModel BuySubscriptionForAllLinesWithStartDate(AccountWebServiceModel account, DateTime startDate) { var dmAccount = new Account { GUID = account.GUID }; SubscriptionWebServiceModel subscription = null; try { subscription = SubscriptionWebServiceModel.FromDataModel(subscriptionService.BuySubscription(dmAccount, startDate)); } catch (Exception) { } return subscription; }
public static SubscriptionWebServiceModel FromDataModel(Subscription subscription, AccountWebServiceModel account) { if (subscription == null) return null; return new SubscriptionWebServiceModel { GUID = subscription.GUID, Account = account, Created = subscription.Created, End = subscription.End, Lines = subscription.Lines.Select(LineWebServiceModel.FromDataModel).ToList(), Start = subscription.Start }; }
/// <summary> /// Buy a new subscription /// </summary> /// <param name="account">The account for which to buy the subscription</param> /// <param name="lines">The lines on which the subscription applies to</param> /// <returns></returns> public SubscriptionWebServiceModel BuySubscription(AccountWebServiceModel account, IEnumerable<LineWebServiceModel> lines) { var dmAccount = new Account { GUID = account.GUID }; var dmLines = lines.Select(l => new Line { GUID = l.GUID }); SubscriptionWebServiceModel subscription = null; try { subscription = SubscriptionWebServiceModel.FromDataModel(subscriptionService.BuySubscription(dmAccount, dmLines)); } catch (Exception) { } return subscription; }
/// <summary> /// Buy a new ticket. /// </summary> /// <param name="account">The account for which to buy the ticket</param> /// <param name="bus">The bus for which to buy the ticket</param> /// <returns></returns> public TicketWebServiceModel BuyTicket(AccountWebServiceModel account, BusWebServiceModel bus) { var dmAccount = new Account() {GUID = account.GUID}; var dmBus = new Bus() {GUID = bus.GUID}; TicketWebServiceModel ticket = null; try { ticket = TicketWebServiceModel.FromDataModel(ticketService.BuyTicket(dmAccount, dmBus), account); } catch (Exception) { } return ticket; }
/// <summary> /// Get older subscriptions. /// </summary> /// <param name="account">The account for which to get the subscriptions</param> /// <param name="before">The date before which to get the subscriptions</param> /// <param name="limit">The max number of subscriptions to fetch</param> /// <returns></returns> public IEnumerable<SubscriptionWebServiceModel> GetNextHistoryWithLimit(AccountWebServiceModel account, DateTime before, int limit) { var dmAccount = new Account { GUID = account.GUID }; return subscriptionService.GetHistory(dmAccount, before, limit) .Select(s => SubscriptionWebServiceModel.FromDataModel(s, account)) .ToList(); }
/// <summary> /// Get the subscriptions that have been added after a given date (used to refresh the list with new values). /// </summary> /// <param name="account">The account for which to get the subscriptions</param> /// <param name="after">The date of the last subscription the client has</param> /// <returns></returns> public IEnumerable<SubscriptionWebServiceModel> GetNewSubscriptions(AccountWebServiceModel account, DateTime after) { var dmAccount = new Account { GUID = account.GUID }; return subscriptionService.GetNewSubscriptions(dmAccount, after) .Select(s => SubscriptionWebServiceModel.FromDataModel(s, account)) .ToList(); }
/// <summary> /// Get all the subscriptions associated to an account. /// </summary> /// <param name="account">The account for which to get the subscriptions</param> /// <returns></returns> public IEnumerable<SubscriptionWebServiceModel> GetHistory(AccountWebServiceModel account) { var dmAccount = new Account { GUID = account.GUID }; return subscriptionService.GetHistory(dmAccount) .Select(s => SubscriptionWebServiceModel.FromDataModel(s, account)) .ToList(); }
/// <summary> /// Get the tickets that have been added after a given date (used to refresh the list with new values). /// </summary> /// <param name="account">The account for which to get the tickets</param> /// <param name="after">The date of the last ticket the client has</param> /// <returns></returns> public IEnumerable<TicketWebServiceModel> GetNewTickets(AccountWebServiceModel account, DateTime after) { var dmAccount = new Account() { GUID = account.GUID }; return ticketService.GetNewTickets(dmAccount, after) .Select(t => TicketWebServiceModel.FromDataModel(t, account)) .ToList(); }
/// <summary> /// Get the currently active ticket of an account. /// </summary> /// <param name="account">The account for which to get the active ticket</param> /// <returns></returns> public TicketWebServiceModel GetActiveTicket(AccountWebServiceModel account) { var dmAccount = new Account() {GUID = account.GUID}; return TicketWebServiceModel.FromDataModel(ticketService.GetActiveTicket(dmAccount), account); }