Exemplo n.º 1
0
        public async Task <bool> Update(Order order)
        {
            using (var context = new OrderAggregateContext()) {
                //ef will mark every thing in graph as Added
                if (order.Validate())
                {
                    context.Orders.Add(order);
                    order.SetModifiedDate();
                    // context.Orders.Add(order);
                    try {
                        if (order.Events.OfType <OrderCreatedWithNoExistingContact>().Any())
                        {
                            //call service to get new contact back to put contactid into customer
                            await GetNewContactIdFromContactApi(order);
                        }
                        context.SaveChanges();
                        return(true);
                    }

                    catch (Exception ex) {
                        throw ex;
                    }
                }
                return(false);
            }
        }
    public async Task<bool> Update(Order order) {
      using (var context = new OrderAggregateContext()) {
        //ef will mark every thing in graph as Added
        if (order.Validate()) {
          context.Orders.Add(order);
          order.SetModifiedDate();
          // context.Orders.Add(order);
          try {
            if (order.Events.OfType<OrderCreatedWithNoExistingContact>().Any()) {
              //call service to get new contact back to put contactid into customer
              await GetNewContactIdFromContactApi(order);
            }
            context.SaveChanges();
            return true;
          }

          catch (Exception ex) {
            throw ex;
          }
        }
        return false;
      }
    }