Exemplo n.º 1
0
        public static PhotosAlbumEditViewModel MapToSctionCardViewModel(this PhotosAlbumVersion sectionCardCreateViewModel)
        {
            PhotosAlbumEditViewModel viewModel = new PhotosAlbumEditViewModel()
            {
                Id = sectionCardCreateViewModel.Id,
                EnPhotosAlbumName     = sectionCardCreateViewModel.EnPhotosAlbumName,
                ArPhotosAlbumName     = sectionCardCreateViewModel.ArPhotosAlbumName,
                EnPhotosAlbumDesc     = sectionCardCreateViewModel.EnPhotosAlbumDesc,
                ArPhotosAlbumDesc     = sectionCardCreateViewModel.ArPhotosAlbumDesc,
                IsActive              = sectionCardCreateViewModel.IsActive,
                IsDeleted             = sectionCardCreateViewModel.IsDeleted,
                ImageUrl              = sectionCardCreateViewModel.ImagePath,
                Order                 = sectionCardCreateViewModel.Order,
                SeoTitleEN            = sectionCardCreateViewModel.SeoTitleEN,
                SeoTitleAR            = sectionCardCreateViewModel.SeoTitleAR,
                SeoDescriptionEN      = sectionCardCreateViewModel.SeoDescriptionEN,
                SeoDescriptionAR      = sectionCardCreateViewModel.SeoDescriptionAR,
                SeoOgTitleEN          = sectionCardCreateViewModel.SeoOgTitleEN,
                SeoOgTitleAR          = sectionCardCreateViewModel.SeoOgTitleAR,
                SeoTwitterCardEN      = sectionCardCreateViewModel.SeoTwitterCardEN,
                SeoTwitterCardAR      = sectionCardCreateViewModel.SeoTwitterCardAR,
                PhotoArchiveVersionId = sectionCardCreateViewModel.PhotoArchiveVersionId
            };

            return(viewModel);
        }
Exemplo n.º 2
0
        //public static List<PhotosAlbumListViewModel> MapToPhotosAlbumViewModel(this IEnumerable<PhotosAlbum> PhotosAlbum)
        //{
        //    return PhotosAlbum.Select(pgMinisty => new PhotosAlbumListViewModel
        //    {
        //        Id = pgMinisty.Id,
        //        EnPhotosAlbumName = pgMinisty.EnPhotosAlbumName,
        //        ArPhotosAlbumName = pgMinisty.ArPhotosAlbumName,
        //        EnPhotosAlbumDesc = pgMinisty.EnPhotosAlbumDesc,
        //        ArPhotosAlbumDesc = pgMinisty.ArPhotosAlbumDesc,
        //        IsActive = pgMinisty.IsActive,
        //        IsDeleted = pgMinisty.IsDeleted,
        //        ImageUrl = pgMinisty.ImagePath,
        //        SeoTitleEN = pgMinisty.SeoTitleEN,
        //        SeoTitleAR = pgMinisty.SeoTitleAR,
        //        SeoDescriptionEN = pgMinisty.SeoDescriptionEN,
        //        SeoDescriptionAR = pgMinisty.SeoDescriptionAR,
        //        SeoOgTitleEN = pgMinisty.SeoOgTitleEN,
        //        SeoOgTitleAR = pgMinisty.SeoOgTitleAR,
        //        SeoTwitterCardEN = pgMinisty.SeoTwitterCardEN,
        //        SeoTwitterCardAR = pgMinisty.SeoTwitterCardAR

        //    }).ToList();
        //}

        public static PhotosAlbumVersion MapToPhotosAlbum(this PhotosAlbumEditViewModel sectionCardCreateViewModel)
        {
            PhotosAlbumVersion pageSectionVersion = new PhotosAlbumVersion();

            pageSectionVersion.EnPhotosAlbumName     = sectionCardCreateViewModel.EnPhotosAlbumName;
            pageSectionVersion.ArPhotosAlbumName     = sectionCardCreateViewModel.ArPhotosAlbumName;
            pageSectionVersion.EnPhotosAlbumDesc     = sectionCardCreateViewModel.EnPhotosAlbumDesc;
            pageSectionVersion.ArPhotosAlbumDesc     = sectionCardCreateViewModel.ArPhotosAlbumDesc;
            pageSectionVersion.IsActive              = sectionCardCreateViewModel.IsActive;
            pageSectionVersion.IsDeleted             = sectionCardCreateViewModel.IsDeleted;
            pageSectionVersion.ImagePath             = sectionCardCreateViewModel.ImageUrl;
            pageSectionVersion.Order                 = sectionCardCreateViewModel.Order;
            pageSectionVersion.PhotoArchiveVersionId = sectionCardCreateViewModel.PhotoArchiveVersionId;

            pageSectionVersion.SeoTitleEN       = sectionCardCreateViewModel.SeoTitleEN;
            pageSectionVersion.SeoTitleAR       = sectionCardCreateViewModel.SeoTitleAR;
            pageSectionVersion.SeoDescriptionEN = sectionCardCreateViewModel.SeoDescriptionEN;
            pageSectionVersion.SeoDescriptionAR = sectionCardCreateViewModel.SeoDescriptionAR;
            pageSectionVersion.SeoOgTitleEN     = sectionCardCreateViewModel.SeoOgTitleEN;
            pageSectionVersion.SeoOgTitleAR     = sectionCardCreateViewModel.SeoOgTitleAR;
            pageSectionVersion.SeoTwitterCardEN = sectionCardCreateViewModel.SeoTwitterCardEN;
            pageSectionVersion.SeoTwitterCardAR = sectionCardCreateViewModel.SeoTwitterCardAR;

            if (sectionCardCreateViewModel.Id > 0)
            {
                pageSectionVersion.Id = sectionCardCreateViewModel.Id;
            }
            return(pageSectionVersion);
        }
        public async Task <IActionResult> EditAsync(PhotosAlbumEditViewModel photosAlbumEditViewModel)
        {
            if (ModelState.IsValid)
            {
                var photosAlbumVersion = photosAlbumEditViewModel.MapToPhotosAlbum();

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

                photosAlbumVersion.ApprovedBy   = user;// user.Id.ToString();
                photosAlbumVersion.ApprovedById = user.Id.ToString();
                photosAlbumVersion.ApprovalDate = DateTime.Now;
                photosAlbumVersion.CreationDate = DateTime.Now;
                if (photosAlbumEditViewModel.ImageFile != null)
                {
                    photosAlbumVersion.ImagePath = _fileService.UploadImageUrlNew(photosAlbumEditViewModel.ImageFile);
                }

                var photosAlbum = _photoAlbumRepository.Update(photosAlbumVersion, photosAlbumEditViewModel.PageRouteId);
                if (photosAlbum != null)
                {
                    _toastNotification.AddSuccessToastMessage("Element has been added successfully. </br> It will take effect after admin approval.");
                    _eventLogger.LogInfoEvent(HttpContext.User.Identity.Name, Common.ActivityEnum.Update, "Photo Album", photosAlbumEditViewModel.ImageUrl);

                    return(RedirectToAction("index", "PhotosAlbum", new { id = photosAlbum.PhotoArchiveVersionId, pageRouteId = photosAlbumEditViewModel.PageRouteId }));
                }
                else
                {
                    _eventLogger.LogInfoEvent(HttpContext.User.Identity.Name, Common.ActivityEnum.Warning, "Photo Archive", photosAlbumEditViewModel.ImageUrl);
                    _toastNotification.AddErrorToastMessage("Error has been occurred");
                }
            }

            return(View(photosAlbumEditViewModel));
        }
        public IActionResult Create(int photoArchiveVerId, int pageRouteId)
        {
            PhotosAlbumEditViewModel viewModel = new PhotosAlbumEditViewModel();

            viewModel.PhotoArchiveVersionId = photoArchiveVerId;
            viewModel.PageRouteId           = pageRouteId;
            return(View(viewModel));
        }
        public PhotosAlbumEditViewModel GetDetail(int id)
        {
            var photoAlbumVersion = GetVersion(id);

            if (photoAlbumVersion != null)
            {
                if (photoAlbumVersion.VersionStatusEnum == VersionStatusEnum.Approved || photoAlbumVersion.VersionStatusEnum == VersionStatusEnum.Ignored)
                {
                    var photoAlbum = Get(photoAlbumVersion.PhotosAlbumId.Value);
                    var model      = new PhotosAlbumEditViewModel
                    {
                        Id = id,
                        EnPhotosAlbumName     = photoAlbum.EnPhotosAlbumName,
                        ArPhotosAlbumName     = photoAlbum.ArPhotosAlbumName,
                        EnPhotosAlbumDesc     = photoAlbum.EnPhotosAlbumDesc,
                        ArPhotosAlbumDesc     = photoAlbum.ArPhotosAlbumDesc,
                        IsActive              = photoAlbum.IsActive,
                        IsDeleted             = photoAlbum.IsDeleted,
                        ImageUrl              = photoAlbum.ImagePath,
                        Order                 = photoAlbum.Order,
                        SeoTitleEN            = photoAlbum.SeoTitleEN,
                        SeoTitleAR            = photoAlbum.SeoTitleAR,
                        SeoDescriptionEN      = photoAlbum.SeoDescriptionEN,
                        SeoDescriptionAR      = photoAlbum.SeoDescriptionAR,
                        SeoOgTitleEN          = photoAlbum.SeoOgTitleEN,
                        SeoOgTitleAR          = photoAlbum.SeoOgTitleAR,
                        SeoTwitterCardEN      = photoAlbum.SeoTwitterCardEN,
                        SeoTwitterCardAR      = photoAlbum.SeoTwitterCardAR,
                        PhotoArchiveVersionId = photoAlbumVersion.PhotoArchiveVersionId,
                        PhotoArchiveId        = photoAlbum.PhotoArchiveId,
                        PhotoAlbumId          = photoAlbum.Id
                    };
                    return(model);
                }
                else
                {
                    var model = new PhotosAlbumEditViewModel
                    {
                        Id = id,
                        EnPhotosAlbumName     = photoAlbumVersion.EnPhotosAlbumName,
                        ArPhotosAlbumName     = photoAlbumVersion.ArPhotosAlbumName,
                        EnPhotosAlbumDesc     = photoAlbumVersion.EnPhotosAlbumDesc,
                        ArPhotosAlbumDesc     = photoAlbumVersion.ArPhotosAlbumDesc,
                        IsActive              = photoAlbumVersion.IsActive,
                        IsDeleted             = photoAlbumVersion.IsDeleted,
                        ImageUrl              = photoAlbumVersion.ImagePath,
                        Order                 = photoAlbumVersion.Order,
                        SeoTitleEN            = photoAlbumVersion.SeoTitleEN,
                        SeoTitleAR            = photoAlbumVersion.SeoTitleAR,
                        SeoDescriptionEN      = photoAlbumVersion.SeoDescriptionEN,
                        SeoDescriptionAR      = photoAlbumVersion.SeoDescriptionAR,
                        SeoOgTitleEN          = photoAlbumVersion.SeoOgTitleEN,
                        SeoOgTitleAR          = photoAlbumVersion.SeoOgTitleAR,
                        SeoTwitterCardEN      = photoAlbumVersion.SeoTwitterCardEN,
                        SeoTwitterCardAR      = photoAlbumVersion.SeoTwitterCardAR,
                        PhotoArchiveVersionId = photoAlbumVersion.PhotoArchiveVersionId,
                        //PhotoArchiveId = photoAlbumVersion.PhotoArchiveId,
                        PhotoAlbumId = photoAlbumVersion.Id
                    };
                    return(model);
                }
            }

            return(null);
        }