Пример #1
0
        public IActionResult Create(int Id)
        {
            var exhibition = _repo.GetExhibition(Id);

            var viewModel = new BannerEditViewModel();

            viewModel.ExhibitionId   = exhibition.Id;
            viewModel.ExhibitionName = exhibition.Name;
            return(View(viewModel));
        }
Пример #2
0
        public async Task <IActionResult> Create(BannerEditViewModel viewModel)
        {
            if (ModelState.IsValid)
            {
                var banner = new Banner();
                banner.Name  = viewModel.Name;
                banner.Image = await ToImageData((viewModel.Image));

                banner.ExhibitionId = viewModel.ExhibitionId;
                banner.Text         = new CustomText();

                banner = _repo.AddBanner(banner);

                return(RedirectToAction("Edit", new { Id = banner.Id }));
            }

            return(View(viewModel));
        }
Пример #3
0
        public static BannerEditViewModel ToEditViewModel(this Banner banner)
        {
            var viewModel = new BannerEditViewModel();

            viewModel.Id                = banner.Id;
            viewModel.Name              = banner.Name;
            viewModel.ExhibitionId      = banner.ExhibitionId;
            viewModel.ImageBase64String = String.Format("data:image;base64,{0}", Convert.ToBase64String(banner.Image));

            if (banner.Text != null)
            {
                viewModel.FixedText    = banner.Text.FixedText;
                viewModel.FontColorHex = banner.Text.FontColorHex;
                viewModel.FontSize     = banner.Text.FontSize;
                viewModel.FontTypeFace = banner.Text.FontTypeFace;
                viewModel.PositionX    = banner.Text.PositionX;
                viewModel.PositionY    = banner.Text.PositionY;
                viewModel.FontTypeFace = banner.Text.FontTypeFace;
            }

            return(viewModel);
        }
Пример #4
0
        public IActionResult Edit(BannerEditViewModel viewModel)
        {
            if (ModelState.IsValid)
            {
                var banner = _repo.GetBanner(viewModel.Id);
                banner.Name         = viewModel.Name;
                banner.ExhibitionId = viewModel.ExhibitionId;


                banner.Text.FixedText    = viewModel.FixedText;
                banner.Text.FontColorHex = viewModel.FontColorHex;
                banner.Text.FontSize     = viewModel.FontSize;
                banner.Text.FontTypeFace = viewModel.FontTypeFace;
                banner.Text.PositionX    = viewModel.PositionX;
                banner.Text.PositionY    = viewModel.PositionY;


                banner = _repo.UpdateBanner(banner);

                return(RedirectToAction("Details", "Exhibition", new { Id = banner.ExhibitionId }));
            }

            return(View(viewModel));
        }