/// <summary> /// Gets the customers. /// </summary> /// <returns></returns> public async Task <IEnumerable <Customer> > GetAllCustomers() { var service = DemoProxy.CustomerService(); var result = await service.GetAllCustomers(); return(result); }
public async Task <int> CustomerCount() { var service = DemoProxy.CustomerService(); var result = await service.CustomerCount(); return(result); }
public async Task <decimal> GetInvoicesTotal() { var aggregator = DemoProxy.InvoiceAggregator("AllInvoices"); var totals = await aggregator.GetInvoiceTotals(); return(totals); }
/// <summary> /// Gets the customer. /// </summary> /// <param name="id">The identifier.</param> /// <returns></returns> public async Task <Customer> GetCustomer(int id) { var service = DemoProxy.CustomerService(); var result = await service.GetCustomer(id); return(result); }
/// <summary> /// Gets the specified key. /// </summary> /// <param name="key">The key.</param> /// <returns></returns> public async Task <string> Get(string key) { var service = DemoProxy.CacheService(key); var value = await service.Get(key); return(value); }
/// <summary> /// Gets the customers. /// </summary> /// <returns></returns> public async Task <IEnumerable <Invoice> > GetAllInvoicesForCustomer(int customerId) { var service = DemoProxy.InvoiceService(); var result = await service.GetAllInvoicesForCustomer(customerId); return(result); }
public async Task <int> AddInvoice(int customerId) { var service = DemoProxy.InvoiceService(); var invoiceId = await service.AddInvoice(customerId); return(invoiceId); }
/// <summary> /// Gets the customer. /// </summary> /// <param name="id">The identifier.</param> /// <returns></returns> public async Task <Invoice> GetInvoice(int id) { var service = DemoProxy.InvoiceService(); var result = await service.GetInvoice(id); return(result); }
public void Test_demo() { // Test iwth real subject DemoClient client = new DemoClient(); RealSubject realSubject = new RealSubject(); client.ClientCode(realSubject); // Test with proxy DemoProxy proxy = new DemoProxy(realSubject); client.ClientCode(proxy); }
public async Task <CounterStats> IncrementClickCount() { try { var counter = DemoProxy.CounterService(); var result = await counter.IncrementClickCount(); return(result); } catch (Exception ex) { return(new CounterStats() { ClickCount = 0, ServedBy = ex.Message }); } }
public async Task UpdateInvoice(Invoice invoice) { var myDictionary = await this.StateManager.GetOrAddAsync <IReliableDictionary <int, List <Invoice> > >("InvoiceData"); var aggregator = DemoProxy.InvoiceAggregator("AllInvoices"); decimal oldTotal = 0; var newTotal = invoice.InvoiceTotal; using (var tx = this.StateManager.CreateTransaction()) { var result = await myDictionary.TryGetValueAsync(tx, 0); var invoices = result.Value; var selectedInvoice = result.Value .FirstOrDefault(_invoice => _invoice.Id == invoice.Id); oldTotal = selectedInvoice.InvoiceTotal; selectedInvoice.Items = invoice.Items; await myDictionary.TryUpdateAsync(tx, 0, invoices, invoices); await tx.CommitAsync(); try { decimal updatedTotal = newTotal - oldTotal; await aggregator.AddToInvoiceTotal(updatedTotal); } catch (Exception e) { Console.WriteLine(e); throw; } } }
public async Task RemoveCustomer(int customerId) { var service = DemoProxy.CustomerService(); await service.RemoveCustomer(customerId); }
public async Task AddCustomer(Customer customer) { var service = DemoProxy.CustomerService(); await service.AddCustomer(customer); }
public async Task AddOrUpdate(string key, [FromBody] string value) { var service = DemoProxy.CacheService(key); await service.AddOrUpdate(key, value); }
public async Task UpdateInvoice(Invoice invoice) { var service = DemoProxy.InvoiceService(); await service.UpdateInvoice(invoice); }