예제 #1
0
        public async Task <IActionResult> SubmitAttractionForm(List <IFormFile> images,
                                                               AttractionFormViewModel attractionFormViewModel)
        {
            if (ModelState.IsValid)
            {
                var attraction = new Attraction()
                {
                    Name              = attractionFormViewModel.Name,
                    Link              = attractionFormViewModel.Link,
                    Description       = attractionFormViewModel.Description,
                    IsVisibleToClient = attractionFormViewModel.IsVisibleToClient,
                    ImageGroup        = new ImageGroup()
                };

                attraction.ImageGroup.Images = new List <Image>();

                WriteImages(images);

                AddImages(ref attraction, images);

                await _attractionRepository.AddAysnc(attraction);

                await _attractionRepository.SaveAsync();

                return(RedirectToAction("LoadActiveAttractions", "Admin"));
            }

            return(View("Forms/_AttractionForm", attractionFormViewModel));
        }