示例#1
0
        public async Task SaveEventAsync <TAggregate>(IDomainEvent @event) where TAggregate : IAggregateRoot
        {
            var aggregateDocument = await _aggregateRepository.GetDocumentAsync(@event.AggregateRootId.ToString());

            if (aggregateDocument == null)
            {
                var newAggregateDocument = _aggregateDocumentFactory.CreateAggregate <TAggregate>(@event);
                await _aggregateRepository.CreateDocumentAsync(newAggregateDocument);
            }

            var currentVersion = await _eventRepository.GetCountAsync(d => d.AggregateId == @event.AggregateRootId);

            var eventDocument = _eventDocumentFactory.CreateEvent(@event, currentVersion + 1);
            await _eventRepository.CreateDocumentAsync(eventDocument);
        }
        public async Task <IActionResult> CreateAsync([Bind("ResortName,Description")] ResortInfo resortInfo,
                                                      List <IFormFile> files)
        {
            if (!ModelState.IsValid)
            {
                return(View(resortInfo));
            }
            resortInfo.ResortId = Guid.NewGuid().ToString();

            var lstBlobDetails = await CreateOrUpdateAnAttachment(files);

            await _documentRepository.CreateDocumentAsync(resortInfo, lstBlobDetails);

            return(RedirectToAction("Index"));
        }