public async Task Prevent_incomplete_event_submissions()
        {
            var mediator = ResolveContainer.MediatR;

            var invalidEvent = new CreateNewEvent.Command
            {
                EventDate = DateTime.Now
            };

            await Should.ThrowAsync <ValidationException>(mediator.Send(invalidEvent));
        }
        public async Task Prevent_duplicate_event()
        {
            var mediator = ResolveContainer.MediatR;

            var command = new CreateNewEvent.Command
            {
                EventDate     = DateTime.Now,
                EventFilename = Guid.NewGuid().ToString(),
                EventName     = "Event name"
            };

            await Should.ThrowAsync <DuplicateRecordException>(mediator.Send(command));
        }
        public async Task <IActionResult> Create(CreateNewEvent.Command command)
        {
            CreateNewEvent.Response result;

            try
            {
                result = await _mediator.Send(command);
            }
            catch (ValidationException e)
            {
                return(View(new ManageEventsViewModel
                {
                    Errors = e.Errors.ToList(),
                    EventDate = command.EventDate,
                    EventFilename = command.EventFilename,
                    EventName = command.EventName
                }));
            }

            return(RedirectToAction(nameof(Index)));
        }