コード例 #1
0
        public void Post([FromBody] ExampleCommand value)
        {
            value.Id = Guid.NewGuid().ToString();
            Aggregate exampleDomain = new ExampleAggregate();

            CommandHandler.ActivateCommand(value, exampleDomain);
        }
コード例 #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());
        }
コード例 #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));
     }
 }
コード例 #4
0
 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()));
     }
 }