Example #1
0
        public ActionResult MediaItemsEdit(BackEndMediaItemsList backEndMediaItemsList, string id)
        {
            if (ModelState.IsValidOrRefresh())
            {
                MediaItems mediaItems = new MediaItems();
                foreach (MediaItem mediaItem in backEndMediaItemsList.MediaItemsList)
                {
                    if (mediaItem.IsMarkedForDeletion)
                    {
                        switch (mediaItems.Delete(mediaItem.MediaItemId))
                        {
                        case 0:
                            ModelState.AddResult(ViewData, ModelStateResult.Success, Resources.Strings.ItemSuccessfullyDeleted + ": " + mediaItem.MediaItemId);
                            break;

                        case 2:
                            ModelState.AddResult(ViewData, ModelStateResult.Error, Resources.Strings.ItemDoesNotExist + ": " + mediaItem.MediaItemId);
                            break;

                        case 3:
                            ModelState.AddResult(ViewData, ModelStateResult.Error, Resources.Strings.ItemUsedSomewhereElse + ": " + mediaItem.MediaItemId);
                            break;

                        default:
                            ModelState.AddResult(ViewData, ModelStateResult.Error, Resources.Strings.UnexpectedError + ": " + mediaItem.MediaItemId);
                            break;
                        }
                    }
                    else
                    {
                        switch (mediaItems.Edit(mediaItem.MediaItemId, (backEndMediaItemsList.SelectedIsMainItem == mediaItem.MediaItemId), mediaItem.Ordering, mediaItem.IsActive, GetLanguageCodesMediaTitles(mediaItem.MediaItemLanguagesTitles)))
                        {
                        case 0:
                            ModelState.AddResult(ViewData, ModelStateResult.Success, Resources.Strings.ItemSuccessfullyEdited + ": " + mediaItem.MediaItemId);
                            break;

                        case 2:
                            ModelState.AddResult(ViewData, ModelStateResult.Error, Resources.Strings.ItemDoesNotExist + ": " + mediaItem.MediaItemId);
                            break;

                        default:
                            ModelState.AddResult(ViewData, ModelStateResult.Error, Resources.Strings.UnexpectedError + ": " + mediaItem.MediaItemId);
                            break;
                        }
                    }
                }
            }

            return(RedirectToAction("MediaItems", new { id = id }));
        }
Example #2
0
        public ActionResult MediaItems(BackEndMediaItemsList backEndMediaItemsList, string id)
        {
            backEndMediaItemsList.MediaGalleryCode = id;

            MediaGallery mediaGallery = new MediaGalleries().GetMediaGallery(id);

            if (mediaGallery.IsNotNull())
            {
                MediaItems mediaItems = new MediaItems();
                backEndMediaItemsList.MediaItemsList = mediaItems.GetMediaItems(id, backEndMediaItemsList.IsActive, backEndMediaItemsList.MediaTypeId);
                if (backEndMediaItemsList.MediaItemsList.IsNull() || backEndMediaItemsList.MediaItemsList.Count == 0)
                {
                    ModelState.AddResult(ViewData, ModelStateResult.Error, Resources.Strings.NoDataFound);
                }
            }
            else
            {
                ModelState.AddResult(ViewData, ModelStateResult.Error, Resources.Strings.ItemDoesNotExist);
                ViewData.IsFormVisible(false);
            }

            return(View(backEndMediaItemsList));
        }