private dynamic CreatedResponse(SpecialOffer newOffer)
 {
     return(Negotiate                                                                      // Negotiate in an entry point to Nancy's fluent API for creating responses.
            .WithStatusCode(HttpStatusCode.Created)                                        // Uses the 201 Created status code for the response
            .WithHeader("Location", $"{Request.Url.SiteBase}/specialoffers/{newOffer.Id}") // Adds a location header to the response because this is expected by HTTP for 201 Created responses.
            .WithModel(newOffer));                                                         // Returns the user in the response for convenience.
 }
        public void Add(SpecialOffer specialOffer)
        {
            var offerId = _database.Keys.Any() ? _database.Keys.Max() + 1 : 1;

            specialOffer.Id = offerId;
            _database.Add(offerId, specialOffer);
            _eventStore.Raise("NewSpecialOffer", specialOffer);
        }
 public void Update(SpecialOffer specialOffer)
 {
     _database[specialOffer.Id] = specialOffer;
     _eventStore.Raise("UpdatedSpecialOffer", specialOffer);
 }