Ejemplo n.º 1
0
        public IActionResult Create(int sectionVersionId, int pageRouteVersionId)
        {
            SectionCardCreateViewModel viewModel = new SectionCardCreateViewModel();

            viewModel.SectionVersionId   = sectionVersionId;
            viewModel.PageRouteVersionId = pageRouteVersionId;
            return(View(viewModel));
        }
Ejemplo n.º 2
0
        public static PageSectionCardVersion MapToSectionCardVersion(this SectionCardCreateViewModel sectionCardCreateViewModel)
        {
            PageSectionCardVersion pageSectionVersion = new PageSectionCardVersion();

            pageSectionVersion.EnTitle              = sectionCardCreateViewModel.EnTitle;
            pageSectionVersion.ArTitle              = sectionCardCreateViewModel.ArTitle;
            pageSectionVersion.EnDescription        = sectionCardCreateViewModel.EnDescription;
            pageSectionVersion.ArDescription        = sectionCardCreateViewModel.ArDescription;
            pageSectionVersion.EnImageAlt           = sectionCardCreateViewModel.EnImageAlt;
            pageSectionVersion.ArImageAlt           = sectionCardCreateViewModel.ArImageAlt;
            pageSectionVersion.ImageUrl             = sectionCardCreateViewModel.ImageUrl;
            pageSectionVersion.Order                = sectionCardCreateViewModel.Order;
            pageSectionVersion.IsActive             = sectionCardCreateViewModel.IsActive;
            pageSectionVersion.PageSectionVersionId = sectionCardCreateViewModel.SectionVersionId;
            return(pageSectionVersion);
        }
Ejemplo n.º 3
0
        public async Task <IActionResult> Create(SectionCardCreateViewModel sectionCardViewModel)
        {
            sectionCardViewModel.EnDescription.ValidateHtml("EnDescription", ModelState);
            sectionCardViewModel.EnDescription.ValidateHtml("ArDescription", ModelState);
            if (sectionCardViewModel.Photo == null || sectionCardViewModel.File == null)
            {
                ModelState.AddModelError(nameof(sectionCardViewModel.Photo), "you should uplaod a photo and file.");
                ModelState.AddModelError(nameof(sectionCardViewModel.File), "you should uplaod a photo and file.");
                _toastNotification.AddWarningToastMessage("you should uplaod a photo and file.");
            }
            if (ModelState.IsValid)
            {
                PageSectionCardVersion sectionCardVersion = sectionCardViewModel.MapToSectionCardVersion();

                sectionCardVersion.ImageUrl = _fileService.UploadImageUrlNew(sectionCardViewModel.Photo);
                sectionCardVersion.FileUrl  = _fileService.UploadFileUrlNew(sectionCardViewModel.File);

                var user = await _userManager.GetUserAsync(HttpContext.User);

                sectionCardVersion.CreatedById  = user.Id;
                sectionCardVersion.CreationDate = DateTime.Now;

                PageSectionCardVersion newPageSectionCardVersion = _sectionCardVersionRepository.Add(sectionCardVersion, sectionCardViewModel.PageRouteVersionId);
                if (newPageSectionCardVersion != null)
                {
                    _eventLogger.LogInfoEvent(HttpContext.User.Identity.Name, Common.ActivityEnum.Add, "Dynamic Page > Card > Add", sectionCardVersion.EnTitle);

                    _toastNotification.AddSuccessToastMessage(ToasrMessages.AddSuccess);
                    return(RedirectToAction("Index", new
                    {
                        id = newPageSectionCardVersion.PageSectionVersionId,
                        pageRouteVersionId = newPageSectionCardVersion.PageSectionVersion.PageRouteVersionId
                    }));
                }
                else
                {
                    _eventLogger.LogInfoEvent(HttpContext.User.Identity.Name, Common.ActivityEnum.Warning, "Dynamic Page > Card > Warning", sectionCardVersion.EnTitle);
                    _toastNotification.AddErrorToastMessage(ToasrMessages.warning);
                }
            }
            return(View(sectionCardViewModel));
        }