예제 #1
0
 private bool ProcessMessage(string message, IDictionary <string, object> headers)
 {
     if (message.Contains("Product"))
     {
         var product = JsonConvert.DeserializeObject <Product>(message);
         if (memoryReportStorage.Get().Any(r => r.ProductName == product.ProductName))
         {
             return(true);
         }
         else
         {
             memoryReportStorage.Add(new Report
             {
                 ProductName = product.ProductName,
                 Count       = DEFAULT_QUANTITY
             });
         }
     }
     else
     {
         var order = JsonConvert.DeserializeObject <Order>(message);
         if (memoryReportStorage.Get().Any(r => r.ProductName == order.Name))
         {
             memoryReportStorage.Get().First(r => r.ProductName == order.Name).Count -= order.Quantity;
         }
         else
         {
             memoryReportStorage.Add(new Report
             {
                 ProductName = order.Name,
                 Count       = DEFAULT_QUANTITY - order.Quantity
             });
         }
     }
     return(true);
 }
예제 #2
0
 public IEnumerable <Report> Get()
 {
     return(memoryReportStorage.Get());
 }