Ejemplo n.º 1
0
        public async Task <IActionResult> Create(CreateConcertViewModel concertModel)
        {
            if (concertModel.ConcertServiceModel.StartDate > concertModel.ConcertServiceModel.EndDate)
            {
                this.TempData.AddErrorMessage("Start Date is after End Date!");
                this.ModelState.AddModelError("", "Start Date is after End Date!");
            }

            if (!this.ModelState.IsValid)
            {
                return(this.View(new CreateConcertViewModel
                {
                    Bands = await this.organizerService.BandsAsync(),
                    ConcertServiceModel = concertModel.ConcertServiceModel
                }));
            }

            var success = await this.organizerService.CreateAsync(concertModel.ConcertServiceModel);

            if (!success)
            {
                return(this.BadRequest());
            }

            this.TempData.AddSuccessMessage($"Successfuly added '{concertModel.ConcertServiceModel.Name}' concert");
            return(this.RedirectToAction(nameof(this.Index)));
        }
Ejemplo n.º 2
0
        public IActionResult Create(CreateConcertViewModel createConcertViewModel)
        {
            if (string.IsNullOrEmpty(createConcertViewModel.Title))
            {
                return(View(createConcertViewModel));
            }

            CreateConcertCommand createConcertCommand = new CreateConcertCommand(createConcertViewModel.NumberOfTickets, createConcertViewModel.Place
                                                                                 , DateTime.Now, createConcertViewModel.Title);

            _bus.Publish(createConcertCommand);

            return(RedirectToAction("Index"));
        }