Esempio n. 1
0
        public ActionResult EditImageSlideList(
            int id,
            EditImageSlideListViewModel imageSlideListViewModel)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    lock (updateLocker)
                    {
                        _managementService.SetImageSlides(
                            id,
                            Mapper.Map<IEnumerable<ImageSlideUpdatingDto>>(
                                imageSlideListViewModel.ImageSlides));
                    }

                    return RedirectToAction("EditTeacherList", new { id });
                }
            }
            catch (WebPageNotFoundException)
            {
                ModelState.AddModelError(String.Empty, _webPageNotFoundError);
            }
            catch (ImageSlideNotFoundException)
            {
                ModelState.AddModelError(String.Empty, _someImageSlidesNotFoundError);
            }
            catch (Exception ex)
            {
                ModelState.AddModelError(String.Empty, _generalError);
                _logger.Error(
                    ex,
                    "Не удалось обновить слайды страницы id='{0}', viewModel='{1}'",
                    id,
                    imageSlideListViewModel);
            }

            var imageDtoList = _fileDisplayingService.GetFileList(UploadedFileTypes.Image);

            imageSlideListViewModel.ImageFiles =
                Mapper.Map<IEnumerable<ShowImageViewModel>>(imageDtoList);

            imageSlideListViewModel.PageId = id;

            return View(imageSlideListViewModel);
        }
Esempio n. 2
0
        /// <summary>
        /// Изменить слайды - подготовка
        /// </summary>
        /// <param name="id">Идентификатор страницы</param>
        /// <returns>Представление для редактирования слайдов</returns>
        public ActionResult EditImageSlideList(int id)
        {
            try
            {
                var imageSlideListViewModel = new EditImageSlideListViewModel();

                var imageSlideDtoList = _managementService.GetImageSlidesForUpdate(id);

                imageSlideListViewModel.ImageSlides = Mapper
                    .Map<IEnumerable<EditImageSlideViewModel>>(imageSlideDtoList)
                    .OrderBy(s => s.SortOrder)
                    .ToList();

                var imageDtoList = _fileDisplayingService.GetFileList(UploadedFileTypes.Image);

                imageSlideListViewModel.ImageFiles =
                    Mapper.Map<IEnumerable<ShowImageViewModel>>(imageDtoList);

                imageSlideListViewModel.PageId = id;

                return View(imageSlideListViewModel);
            }
            catch (WebPageNotFoundException)
            {
                return HttpNotFound();
            }
        }