public void Post([FromBody] ExampleCommand value)
        {
            value.Id = Guid.NewGuid().ToString();
            Aggregate exampleDomain = new ExampleAggregate();

            CommandHandler.ActivateCommand(value, exampleDomain);
        }
Esempio n. 2
0
        public ActionResult AcceptBasicAgregate([FromBody] AddNewBook addNewBook)
        {
            if (string.IsNullOrEmpty(addNewBook.Id))
            {
                addNewBook.Id = Guid.NewGuid().ToString();
            }
            //if(addNewBook.Id == Guid.Empty) addNewBook.Id = Guid.NewGuid();
            BookAggregate aggregate = new BookAggregate();

            CommandHandler.ActivateCommand(addNewBook, aggregate);
            return(Ok());
        }
Esempio n. 3
0
 public ActionResult CloseBasicAgregate([FromBody] RemoveBook removeBook)
 {
     try
     {
         removeBook.Id = removeBook.Id.ToLower();
         BookAggregate aggregate = new BookAggregate();
         CommandHandler.ActivateCommand(removeBook, aggregate);
         return(Ok());
     }
     catch (Exception e)
     {
         return(BadRequest(e.Message));
     }
 }
 public ActionResult Example([FromBody] ExampleCommand example)
 {
     try
     {
         //Commands inherit Id from their base class, this data is used to create the eventstream Id.
         //If that stream is derived from fields in the command or event other than a simple Id, this is the place to make assign it.
         Aggregate exampleAggreate = new ExampleAggregate();
         CommandHandler.ActivateCommand(example, exampleAggreate);
         return(Ok(example.Id));
     }
     catch (Exception e)
     {
         return(BadRequest(e.Message.ToString()));
     }
 }