Exemple #1
0
        public object Post(CreateLinkEventRequest request)
        {
            var link = _linkRepo.GetByKey(request.Key);

            if (link == null)
            {
                throw HttpError.NotFound($"Link with key '{request.Key}' not found.");
            }

            UnitOfWork(() =>
            {
                var c       = request.ConvertTo <LinkEvent>();
                c.LinkId    = link.Id;
                c.CreatedAt = DateTime.UtcNow;
                c.SessionId = Session.Id;
                _linkRepo.CreateLinkEvent(c);

                _domainEventBus.Handle(new LinkEventCreatedEvent(c));
            });

            return(_linkRepo.GetLinkResponse(link.Id));
        }