Exemplo n.º 1
0
        private void HandleDelete(IEnumerable <RoleMedia> RoleMediaDetails)
        {
            selectedItem = BaseMapper.GetObjectFromContext((MediaDetail)selectedItem);
            Role   role = null;
            Return obj  = BaseMapper.GenerateReturn();

            foreach (RoleMedia RoleMediaDetail in RoleMediaDetails)
            {
                obj  = RolesMediasMapper.DeletePermanently(RoleMediaDetail);
                role = RoleMediaDetail.Role;
            }

            if (!obj.IsError)
            {
                IEnumerable <UserMedia> userMediaDetails = selectedItem.Media.UsersMedias.Where(i => i.User.IsInRole(role));

                foreach (UserMedia userMediaDetail in userMediaDetails)
                {
                    UsersMediasMapper.DeletePermanently(userMediaDetail);
                }

                Bind();
            }

            if (obj.IsError)
            {
                BasePage.DisplayErrorMessage("Error deleting association", obj.Error);
            }
            else
            {
                BasePage.DisplaySuccessMessage("Successfully deleted association");
                Bind();
            }
        }
Exemplo n.º 2
0
        protected void RemoveFromUser_OnClick(object sender, EventArgs e)
        {
            var currentMediaDetail = BaseMapper.GetObjectFromContext((MediaDetail)MediaDetailToAdd);
            var found = currentMediaDetail.Media.UsersMedias.SingleOrDefault(i => i.MediaID == currentMediaDetail.MediaID);

            if (found == null)
            {
                return;
            }

            var returnObj = UsersMediasMapper.DeletePermanently(found);

            if (!returnObj.IsError)
            {
                currentMediaDetail.Media.UsersMedias.Remove(found);
                returnObj = MediaDetailsMapper.Update(currentMediaDetail);
                UpdateVisibility();
            }

            if (!returnObj.IsError)
            {
                BasePage.DisplaySuccessMessage("Successfully removed from My Plan");
            }
            else
            {
                BasePage.DisplayErrorMessage("Error removing from My Plan", returnObj.Error);
            }
        }
Exemplo n.º 3
0
        protected void Save_OnClick(object sender, EventArgs e)
        {
            if (!canAccessSection)
            {
                return;
            }

            var settings = BaseMapper.GetObjectFromContext(SettingsMapper.GetSettings());

            UpdateObjectFromFields(settings);

            var returnObj = SettingsMapper.Update(settings);

            if (returnObj.IsError)
            {
                DisplayErrorMessage("Error saving settings", returnObj.Error);
            }
            else
            {
                ContextHelper.ClearAllMemoryCache();
                FileCacheHelper.ClearAllCache();

                SettingsMapper.ClearCache();

                DisplaySuccessMessage("Successfully saved settings");
            }
        }
Exemplo n.º 4
0
        private Return SaveHistory(IMediaDetail history)
        {
            selectedItem = BaseMapper.GetObjectFromContext((MediaDetail)selectedItem);
            history.HistoryForMediaDetailID = selectedItem.ID;

            if (selectedItem.History.Count == 0)
            {
                history.HistoryVersionNumber = 1;
            }
            else
            {
                history.HistoryVersionNumber = selectedItem.History.OrderByDescending(i => i.HistoryVersionNumber).Take(1).FirstOrDefault().HistoryVersionNumber + 1;
            }

            if (selectedItem.History.Count >= MediaDetailsMapper.MaxHistory)
            {
                int count = selectedItem.History.Count - MediaDetailsMapper.MaxHistory;
                IEnumerable <MediaDetail> items = selectedItem.History.OrderBy(i => i.HistoryVersionNumber).Take(count);

                foreach (MediaDetail item in items)
                {
                    if (!item.IsDraft)
                    {
                        MediaDetailsMapper.ClearObjectRelations(item);
                        MediaDetailsMapper.DeleteObjectFromContext(item);
                    }
                }
            }

            /*if (history.MainContent.Trim() == "")
             *  history.MainContent = "TBD";*/

            return(MediaDetailsMapper.Insert(history));
        }
Exemplo n.º 5
0
        protected void AddToUser_OnClick(object sender, EventArgs e)
        {
            var usersMediaDetails = new UserMedia();

            usersMediaDetails.MediaID     = MediaDetailToAdd.MediaID;
            usersMediaDetails.UserID      = BasePage.CurrentUser.ID;
            usersMediaDetails.DateCreated = usersMediaDetails.DateLastModified = DateTime.Now;
            //usersMediaDetails.PermissionID = PermissionsMapper.GetPermissionsFromEnum(PermissionsEnum.AccessProtectedSections).ID;

            var currentMediaDetail = BaseMapper.GetObjectFromContext((MediaDetail)MediaDetailToAdd);

            currentMediaDetail.Media.UsersMedias.Add(usersMediaDetails);

            var returnObj = MediaDetailsMapper.Update(currentMediaDetail);

            if (!returnObj.IsError)
            {
                BasePage.DisplaySuccessMessage("Successfully added to My Plan");
                UpdateVisibility();
            }
            else
            {
                BasePage.DisplayErrorMessage("Error adding to My Plan", returnObj.Error);
            }
        }
        private void SetDeleteStatus(IMediaDetail detail, bool isDeleted)
        {
            UserMustHaveAccessTo(detail);

            if (!FrameworkSettings.CurrentUser.HasPermission(PermissionsEnum.Delete))
            {
                throw new Exception("You do not have the appropriate permissions to delete/undelete items");
            }

            detail           = BaseMapper.GetObjectFromContext((MediaDetail)detail);
            detail.IsDeleted = isDeleted;

            Return returnObj = MediaDetailsMapper.Update(detail);

            if (returnObj.IsError)
            {
                throw returnObj.Error.Exception;
            }
            else
            {
                ContextHelper.ClearAllMemoryCache();
                detail.RemoveFromCache();
                FileCacheHelper.DeleteCacheDir("generatenav");
            }
        }
        private void HandleDelete(IEnumerable <UserMedia> selectedUserMediaDetails)
        {
            selectedItem = BaseMapper.GetObjectFromContext((MediaDetail)selectedItem);
            Return obj = BaseMapper.GenerateReturn();

            foreach (UserMedia selectedUserMediaDetail in selectedUserMediaDetails)
            {
                UserMedia item = BaseMapper.GetObjectFromContext(selectedUserMediaDetail);
                selectedItem.Media.UsersMedias.Remove(selectedUserMediaDetail);
                obj = UsersMediasMapper.DeletePermanently(selectedUserMediaDetail);

                if (obj.IsError)
                {
                    break;
                }
            }

            if (obj.IsError)
            {
                BasePage.DisplayErrorMessage("Error deleting association", obj.Error);
            }
            else
            {
                BasePage.DisplaySuccessMessage("Successfully deleted association");
                Bind();
            }
        }
Exemplo n.º 8
0
        public void UpdateObjectFromFields()
        {
            selectedItem.CanLimitedRolesAccessAllChildPages = CanLimitedRolesAccessAllChildPages.Checked;
            selectedItem.EnforceRoleLimitationsOnFrontEnd   = EnforceRoleLimitationOnFrontEnd.Checked;

            var roles = MultiRoleSelector.GetSelectedRoles();

            if (roles == null)
            {
                return;
            }

            var rolesMedias = selectedItem.Media.RolesMedias.ToList();

            foreach (var roleMedia in rolesMedias)
            {
                BaseMapper.DeleteObjectFromContext(roleMedia);
            }

            foreach (var role in roles)
            {
                var contextRole  = BaseMapper.GetObjectFromContext(role);
                var newMediaRole = new RoleMedia()
                {
                    Media = selectedItem.Media, Role = contextRole, DateCreated = DateTime.Now, DateLastModified = DateTime.Now
                };

                selectedItem.Media.RolesMedias.Add(newMediaRole);
            }
        }
        protected void Save_OnClick(object sender, EventArgs e)
        {
            selectedItem = BaseMapper.GetObjectFromContext((MediaDetail)selectedItem);
            IEnumerable <UserMedia> UserMediaDetails = UserPermissionsSelector.GetUserMediaDetails();

            User User = UserPermissionsSelector.GetSelectedUser();
            IEnumerable <UserMedia> removeItems = selectedItem.Media.UsersMedias.Where(i => i.UserID == User.ID);

            foreach (UserMedia removeItem in removeItems)
            {
                UsersMediasMapper.DeletePermanently(removeItem);
            }

            foreach (UserMedia UserMediaDetail in UserMediaDetails)
            {
                selectedItem.Media.UsersMedias.Add(UserMediaDetail);
            }

            Return obj = MediaDetailsMapper.Update(selectedItem);

            if (obj.IsError)
            {
                BasePage.DisplayErrorMessage("Error assigning User", obj.Error);
            }
            else
            {
                BasePage.DisplaySuccessMessage("Successfully assigned User");
                Bind();
                EditPanel.Visible = false;
            }
        }
        public string HandleNodeDragDrop(long sourceMediaId, long parentMediaId, int newPosition)
        {
            var sourceMedia = BaseMapper.GetObjectFromContext(MediasMapper.GetByID(sourceMediaId));
            var parentMedia = BaseMapper.GetObjectFromContext(MediasMapper.GetByID(parentMediaId));

            UserMustHaveAccessTo(sourceMedia.GetLiveMediaDetail());

            var oldParentId = sourceMedia.ParentMediaID;

            sourceMedia.MoveToIndex(newPosition);

            sourceMedia.ParentMedia = parentMedia;

            if (oldParentId != parentMedia.ID)
            {
                foreach (var item in sourceMedia.MediaDetails)
                {
                    item.CachedVirtualPath = item.CalculatedVirtualPath();
                }
            }

            var returnObj = MediasMapper.Update(sourceMedia);

            return(returnObj.ToJson());
        }
Exemplo n.º 11
0
        protected void Save_OnClick(object sender, EventArgs e)
        {
            if (selectedItem == null)
            {
                selectedItem = GlossaryTermsMapper.CreateObject();
            }
            else
            {
                selectedItem = BaseMapper.GetObjectFromContext <GlossaryTerm>(selectedItem);
            }

            UpdateObjectFromFields();

            Return returnObj;

            if (selectedItem.ID == 0)
            {
                returnObj = GlossaryTermsMapper.Insert(selectedItem);
            }
            else
            {
                returnObj = GlossaryTermsMapper.Update(selectedItem);
            }

            if (returnObj.IsError)
            {
                DisplayErrorMessage("Error Saving Item", returnObj.Error);
            }
            else
            {
                UpdateFieldsFromObject();
                DisplaySuccessMessage("Successfully Saved Item");
            }
        }
Exemplo n.º 12
0
        protected void Save_OnClick(object sender, EventArgs e)
        {
            selectedItem = BaseMapper.GetObjectFromContext((MediaDetail)selectedItem);
            IEnumerable <RoleMedia> RoleMediaDetails = RolePermissionsSelector.GetRoleMediaDetails();

            Role role = RolePermissionsSelector.GetSelectedRole();
            IEnumerable <RoleMedia> removeItems = selectedItem.Media.RolesMedias.Where(i => i.RoleID == role.ID);

            foreach (RoleMedia removeItem in removeItems)
            {
                RolesMediasMapper.DeletePermanently(removeItem);
            }

            foreach (RoleMedia RoleMediaDetail in RoleMediaDetails)
            {
                selectedItem.Media.RolesMedias.Add(RoleMediaDetail);
            }

            Return obj = MediaDetailsMapper.Update(selectedItem);

            if (obj.IsError)
            {
                BasePage.DisplayErrorMessage("Error assigning role", obj.Error);
            }
            else
            {
                BasePage.DisplaySuccessMessage("Successfully assigned role");
                Bind();
                EditPanel.Visible = false;
            }
        }
Exemplo n.º 13
0
        private void UpdateObjectFromFields()
        {
            SelectedItem.UserName = Username.Text;

            var password          = Password.Text.Trim();
            var encryptedPassword = StringHelper.Encrypt(password);

            if (password != "")
            {
                SelectedItem.Password = encryptedPassword;
            }

            SelectedItem.EmailAddress        = EmailAddress.Text;
            SelectedItem.IsActive            = IsActive.Checked;
            SelectedItem.ProfilePhoto        = ProfilePhoto.GetValue().ToString();
            SelectedItem.FirstName           = FirstName.Text;
            SelectedItem.LastName            = LastName.Text;
            SelectedItem.AfterLoginStartPage = AfterLoginStartPage.Text;

            SelectedItem.Roles.Clear();

            foreach (ListItem item in RolesList.Items)
            {
                if (item.Selected)
                {
                    SelectedItem.Roles.Add(BaseMapper.GetObjectFromContext <Role>(RolesMapper.GetByID(long.Parse(item.Value))));
                }
            }
        }
Exemplo n.º 14
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (CurrentMedia == null)
            {
                CurrentMedia = BaseMapper.GetObjectFromContext((Media)BasePage.CurrentMedia);
            }

            //Bind();
        }
Exemplo n.º 15
0
        public IEnumerable <Tag> GetTags()
        {
            var items = new List <Tag>();
            IEnumerable <string> values = TagValues.Value.Trim().Split(',').Distinct();

            var count = 0;

            foreach (string value in values)
            {
                var tagName = value.Trim();

                var lowerCaseTagName = tagName.ToLower();

                if ((tagName == "") || (items.Any(i => i.Name.ToLower() == lowerCaseTagName)))
                {
                    continue;
                }

                long id;
                long.TryParse(tagName, out id);
                Tag item = null;

                if (id != 0)
                {
                    item = TagsMapper.GetByID(long.Parse(tagName));
                }

                if (item == null)
                {
                    item = TagsMapper.GetByName(tagName);
                }

                if (item != null)
                {
                    item = BaseMapper.GetObjectFromContext <Tag>(item);
                }

                if ((item == null) || (item.ID == 0))
                {
                    item             = TagsMapper.CreateObject();
                    item.Name        = tagName;
                    item.Description = tagName;
                    item.OrderIndex  = count;
                    item.SefTitle    = URIHelper.PrepairUri(tagName);
                    item.DateCreated = item.DateLastModified = DateTime.Now;
                }

                if (item != null)
                {
                    items.Add(item);
                }

                count++;
            }

            return(items);
        }
Exemplo n.º 16
0
        protected void PublishNow_OnClick(object sender, EventArgs e)
        {
            if (!CurrentUser.HasPermission(PermissionsEnum.Publish))
            {
                DisplayErrorMessage("Error publishing item", ErrorHelper.CreateError(new Exception("You do not have the appropriate permissions to publish items")));
                return;
            }

            selectedItem = BaseMapper.GetObjectFromContext((MediaDetail)selectedItem);

            if (selectedItem == null)
            {
                return;
            }

            var mediaType = MediaTypesMapper.GetByID(selectedItem.MediaTypeID);

            selectedItem.PublishDate = DateTime.Now;

            if (selectedItem.ExpiryDate != null)
            {
                selectedItem.ExpiryDate = null;
            }

            selectedItem.ShowInMenu          = mediaType.ShowInMenu;
            selectedItem.ShowInSearchResults = mediaType.ShowInSearchResults;
            selectedItem.EnableCaching       = mediaType.EnableCaching;

            Return returnObj = MediaDetailsMapper.Update(selectedItem);

            if (returnObj.IsError)
            {
                DisplayErrorMessage("Error Publishing Item", returnObj.Error);
            }
            else
            {
                DisplaySuccessMessage("Successfully Published Item");

                var mediaId = (selectedItem.Media.ParentMediaID != null) ? selectedItem.Media.ParentMediaID : selectedItem.MediaID;

                ExecuteRawJS("RefreshSiteTreeNodeById(" + mediaId + "); ReloadPreviewPanel();");

                UpdateFieldsFromObject();

                PublishNow.Visible = false;
                ContextHelper.Clear(ContextType.Cache);
                FileCacheHelper.ClearAllCache();
            }

            UpdateFieldsFromObject();

            OnPublishExecuteCode();
        }
Exemplo n.º 17
0
        protected void Save_OnClick(object sender, EventArgs e)
        {
            if (selectedItem == null)
            {
                selectedItem = LanguagesMapper.CreateObject();
            }
            else
            {
                selectedItem = BaseMapper.GetObjectFromContext <Language>(selectedItem);
            }

            UpdateObjectFromFields();

            Return returnObj = selectedItem.Validate();

            if (!returnObj.IsError)
            {
                if (selectedItem.ID == 0)
                {
                    returnObj = LanguagesMapper.Insert(selectedItem);
                }
                else
                {
                    returnObj = LanguagesMapper.Update(selectedItem);
                }
            }

            if (returnObj.IsError)
            {
                DisplayErrorMessage("Error Saving Item", returnObj.Error);
            }
            else
            {
                DisplaySuccessMessage("Successfully Saved Item");
                LanguagesMapper.ClearAllActiveCache();


                /*var rootDetails = BaseMapper.GetObjectFromContext((MediaDetail)FrameworkBaseMedia.RootMediaDetail);
                 * rootDetails.VirtualPath = URIHelper.GetBaseUrlWithLanguage(selectedItem);*/

                /*returnObj = MediaDetailsMapper.Update(rootDetails);
                 *
                 * if (!returnObj.IsError)
                 *  MediaDetailsMapper.StartUpdateVirtualPathForAllChildren(rootDetails);
                 * else
                 *  DisplaySuccessMessage("Error updating root media item");*/
            }
        }
Exemplo n.º 18
0
        protected void DeletePermanently_OnClick(object sender, EventArgs e)
        {
            Comment comment = CommentsMapper.GetByID(long.Parse(((Button)sender).CommandArgument));

            comment = BaseMapper.GetObjectFromContext <Comment>(comment);

            //comment.MediaDetails.Clear();
            Return obj = CommentsMapper.DeletePermanently(comment);

            if (obj.IsError)
            {
                this.BasePage.DisplayErrorMessage("Error", obj.Error);
            }

            SetComments(statusEnum, mode, media);
        }
        private void HandleDelete(IMediaDetail item)
        {
            Return returnObj = MediaDetailsMapper.DeletePermanently((MediaDetail)item);

            if (returnObj.IsError)
            {
                BasePage.DisplayErrorMessage("Error deleting association", returnObj.Error);
            }
            else
            {
                BasePage.DisplaySuccessMessage("Successfully deleted association");
                selectedItem = BaseMapper.GetObjectFromContext((MediaDetail)selectedItem);

                Bind();
            }
        }
Exemplo n.º 20
0
        protected void Reject_OnClick(object sender, EventArgs e)
        {
            Comment comment = CommentsMapper.GetByID(long.Parse(((Button)sender).CommandArgument));

            comment = BaseMapper.GetObjectFromContext <Comment>(comment);

            comment.Status = StatusEnum.Rejected.ToString();
            Return obj = CommentsMapper.Update(comment);

            if (obj.IsError)
            {
                this.BasePage.DisplayErrorMessage("Error", obj.Error);
            }

            SetComments(statusEnum, mode, media);
        }
Exemplo n.º 21
0
        private void UpdateObjectFromFields()
        {
            SelectedItem.IsActive    = IsActive.Checked;
            SelectedItem.Name        = Name.Text;
            SelectedItem.Description = Description.Text;
            SelectedItem.EnumName    = EnumName.Text;

            IEnumerable <Permission> items = PermissionsSelector.GetSelectedPermissions();

            SelectedItem.Permissions.Clear();

            foreach (Permission item in items)
            {
                SelectedItem.Permissions.Add(BaseMapper.GetObjectFromContext(item));
            }
        }
        private void HandleDeletePermanently(Media item)
        {
            if (!FrameworkSettings.CurrentUser.HasPermission(PermissionsEnum.Delete))
            {
                throw new Exception("You do not have the appropriate permissions to delete items permanently");
            }

            if (item == null)
            {
                return;
            }

            MediaDetail detail      = (MediaDetail)GetAtleastOneByMedia(item);
            Media       parentMedia = null;

            if (item.ParentMediaID != null)
            {
                parentMedia = MediasMapper.GetByID((long)item.ParentMediaID);
            }

            Return returnObj = BaseMapper.GenerateReturn("No action performed");

            if (detail == null)
            {
                if (item.ChildMedias.Count == 0)
                {
                    returnObj = MediasMapper.DeletePermanently(item);
                }
            }
            else
            {
                item = BaseMapper.GetObjectFromContext(item);
                if ((item.MediaDetails.Count == 1) && (item.ChildMedias.Count > 0))
                {
                    throw new Exception("You cannot delete this item because it has child items");
                }

                detail    = BaseMapper.GetObjectFromContext(detail);
                returnObj = MediaDetailsMapper.DeletePermanently(detail);

                if (!returnObj.IsError)
                {
                    ContextHelper.ClearAllMemoryCache();
                    detail.RemoveFromCache();
                }
            }
        }
Exemplo n.º 23
0
        protected void Save_OnClick(object sender, EventArgs e)
        {
            if (!canAccessSection)
            {
                return;
            }

            if (SelectedItem == null)
            {
                SelectedItem = UsersMapper.CreateObject();
            }
            else
            {
                SelectedItem = BaseMapper.GetObjectFromContext <User>(SelectedItem);
            }

            SelectedItem.AuthenticationType = AuthType.Forms.ToString();
            SelectedItem.ResetCode          = "";

            UpdateObjectFromFields();

            Return returnObj = SelectedItem.Validate();

            if (!returnObj.IsError)
            {
                if (SelectedItem.ID == 0)
                {
                    returnObj = UsersMapper.Insert(SelectedItem);
                }
                else
                {
                    returnObj = UsersMapper.Update(SelectedItem);
                }
            }

            if (returnObj.IsError)
            {
                DisplayErrorMessage("Error Saving Item", returnObj.Error);
            }
            else
            {
                DisplaySuccessMessage("Successfully Saved Item");
            }
        }
Exemplo n.º 24
0
        protected void Save_OnClick(object sender, EventArgs e)
        {
            if (selectedItem == null)
            {
                selectedItem = MediaTypesMapper.CreateObject();
            }
            else
            {
                selectedItem = BaseMapper.GetObjectFromContext <MediaType>(selectedItem);
            }

            UpdateObjectFromFields();

            Return returnObj = selectedItem.Validate();

            if (!returnObj.IsError)
            {
                if (selectedItem.ID == 0)
                {
                    returnObj = MediaTypesMapper.Insert(selectedItem);
                }
                else
                {
                    returnObj = MediaTypesMapper.Update(selectedItem);
                }
            }

            if (returnObj.IsError)
            {
                DisplayErrorMessage("Error Saving Item", returnObj.Error);
            }
            else
            {
                /*var mediaDetails = selectedItem.MediaDetails.Where(i => i.HistoryForMediaDetail == null);
                 *
                 * foreach (var mediaDetail in mediaDetails)
                 * {
                 *  mediaDetail.RemoveFromCache();
                 * }*/

                DisplaySuccessMessage("Successfully Saved Item");
            }
        }
Exemplo n.º 25
0
        public string DeleteItemPermanently(long id)
        {
            MediaType item = BaseMapper.GetObjectFromContext(MediaTypesMapper.GetByID(id));

            if (item != null)
            {
                Return returnObj = MediaTypesMapper.DeletePermanently(item);

                if (returnObj.IsError)
                {
                    return(jGrowlHelper.GenerateCode(new jGrowlMessage("Error", "Error deleting item permanently", jGrowlMessage.jGrowlMessageType.Error, returnObj.Error), true));
                }
                else
                {
                    return(jGrowlHelper.GenerateCode(new jGrowlMessage("Success", "Item was successfully deleted permanently", jGrowlMessage.jGrowlMessageType.Success), false));
                }
            }

            return("");
        }
Exemplo n.º 26
0
        private IMediaDetail CreateHistory(MediaDetail fromItem, bool isDraft)
        {
            if (fromItem == null)
            {
                return(null);
            }

            IMediaDetail history = null;

            if ((selectedItem.ID != 0) && (historyVersion == 0))
            {
                history = MediaDetailsMapper.CreateObject(fromItem.MediaTypeID, fromItem.Media, fromItem.Media.ParentMedia, false);
                history.CopyFrom(BaseMapper.GetObjectFromContext(fromItem));
                history.IsDraft = isDraft;

                CopyProperties(history, fromItem);
            }

            return(history);
        }
Exemplo n.º 27
0
        public string TakeOwnership(long id)
        {
            User item = BaseMapper.GetObjectFromContext(UsersMapper.GetByID(id));

            if (item != null)
            {
                Return returnObj = UsersMapper.TransferOwnership(item, FrameworkSettings.CurrentUser);

                if (returnObj.IsError)
                {
                    return(jGrowlHelper.GenerateCode(new jGrowlMessage("Error", "Error taking ownership", jGrowlMessage.jGrowlMessageType.Error, returnObj.Error), true));
                }
                else
                {
                    return(jGrowlHelper.GenerateCode(new jGrowlMessage("Success", "Successfully took ownership of all items assigned to user: (" + item.UserName + ")", jGrowlMessage.jGrowlMessageType.Success), false));
                }
            }

            return("");
        }
        private Return SetPublishStatus(MediaDetail detail, bool publishStatus)
        {
            if ((detail == null) || (detail.IsPublished == publishStatus))
            {
                return(new Return());
            }

            detail = BaseMapper.GetObjectFromContext(detail);

            if (publishStatus)
            {
                detail.PublishDate = DateTime.Now;
            }
            else
            {
                detail.PublishDate = null;
            }

            Return returnObj = MediaDetailsMapper.Update(detail);

            if (returnObj.IsError)
            {
                return(returnObj);
            }
            else
            {
                ContextHelper.ClearAllMemoryCache();
                FileCacheHelper.DeleteCacheDir("generatenav");

                if (publishStatus)
                {
                    detail.PublishDate = DateTime.Now;

                    returnObj = detail.RunOnPublishExecuteCode();

                    return(returnObj);
                }

                return(returnObj);
            }
        }
Exemplo n.º 29
0
        private void HandleDeleteAssociation(Media selectedMedia)
        {
            selectedItem  = BaseMapper.GetObjectFromContext <Tag>(selectedItem);
            selectedMedia = BaseMapper.GetObjectFromContext <Media>(selectedMedia);

            var mediaTag = selectedItem.MediaTags.SingleOrDefault(i => i.MediaID == selectedMedia.ID);

            selectedItem.MediaTags.Remove(mediaTag);

            Return obj = TagsMapper.Update(selectedItem);

            if (obj.IsError)
            {
                BasePage.DisplayErrorMessage("Error deleting association", obj.Error);
            }
            else
            {
                BasePage.DisplaySuccessMessage("Successfully deleted association");
                Bind();
            }
        }
        private void SetShowInMenuStatus(MediaDetail detail, bool showInMenu)
        {
            if ((detail == null) || (detail.ShowInMenu == showInMenu))
            {
                return;
            }

            detail            = BaseMapper.GetObjectFromContext(detail);
            detail.ShowInMenu = showInMenu;

            Return returnObj = MediaDetailsMapper.Update(detail);

            if (returnObj.IsError)
            {
                throw returnObj.Error.Exception;
            }
            else
            {
                ContextHelper.ClearAllMemoryCache();
                FileCacheHelper.DeleteCacheDir("generatenav");
            }
        }