Esempio n. 1
0
        public static JqGridResponse Edit(EditCommentManagementVM model, ProviderCurrentMember currentMember)
        {
            JqGridResponse aResponse = new JqGridResponse();
            ProviderComment aComment = new ProviderComment(model.Id);
            if (currentMember.CanEdit(aComment))
            {
                aComment.IgnoreFlags = model.IgnoreFlags;
                aComment.IsHidden = model.IsHidden;
                try
                {
                    aComment.Save();
                    aResponse.Success = true;
                }
                catch(Exception caughtException)
                {
                    aResponse.Success = false;
                    aResponse.Message = ErrorStrings.OPERATION_FAILED;
                }
            }
            else
            {
                aResponse.Success = false;
                aResponse.Message = ErrorStrings.OPERATION_NO_RIGHTS;
            }

            return aResponse;
        }
Esempio n. 2
0
        public static JqGridResponse Edit(EditMemberManagementVM model, ProviderCurrentMember currentMember)
        {
            JqGridResponse aResponse = new JqGridResponse();
            ProviderMember aMember = new ProviderMember(model.Id);

            if (currentMember.CanEdit(aMember))
            {
                aMember.IsArticleAdmin = model.IsArticleAdmin;
                aMember.IsBanned = model.IsBanned;
                aMember.IsCategoryAdmin = model.IsCategoryAdmin;
                aMember.IsMasterAdmin = model.IsMasterAdmin;
                aMember.IsMemberAdmin = model.IsMemberAdmin;
                aMember.IsSuperAdmin = model.IsSuperAdmin;

                try
                {
                    aMember.Save();
                    aResponse.Success = true;
                }
                catch (Exception caughtException)
                {
                    aResponse.Success = false;
                    aResponse.Message = ErrorStrings.OPERATION_FAILED;
                }
            }
            else
            {
                aResponse.Success = false;
                aResponse.Message = ErrorStrings.OPERATION_NO_RIGHTS;
            }

            return aResponse;
        }
Esempio n. 3
0
        public static bool Save(CategoryEditVM model, ProviderCurrentMember currentMember)
        {
            bool returnValue = false;
            ProviderCategory aCategory;
            if (ProviderCategory.Exists(model.Id))
            {
                aCategory = new ProviderCategory(model.Id);
            }
            else
            {
                aCategory = new ProviderCategory();
            }

            if (currentMember.CanEdit(aCategory))
            {
                aCategory.Title = model.Title;
                aCategory.EditDate = DateTime.UtcNow;
                aCategory.IsHidden = model.IsHidden;
                aCategory.ParentId = model.ParentId;
                try
                {
                    aCategory.Save();
                    InsideWordWebStaticCache.Instance.ClearCache();
                    returnValue = true;
                }
                catch (Exception caughtException)
                {
                    returnValue = false;
                }
            }

            return returnValue;
        }
Esempio n. 4
0
 public AdminIndexVM(ProviderCurrentMember currentMember)
 {
     CanAccessArticleManagement = currentMember.CanAccess(ProviderCurrentMember.AccessGroup.ArticleManagement);
     CanAccessCategoryManagement = currentMember.CanAccess(ProviderCurrentMember.AccessGroup.CategoryManagement);
     CanAccessConversationManagement = currentMember.CanAccess(ProviderCurrentMember.AccessGroup.ConversationManagement);
     CanAccessMemberManagement = currentMember.CanAccess(ProviderCurrentMember.AccessGroup.MemberManagement);
     CanAccessSettingsManagement = currentMember.CanAccess(ProviderCurrentMember.AccessGroup.Administration);
 }
Esempio n. 5
0
 public bool Parse(ProviderGroup aGroup, ProviderCurrentMember currentMember)
 {
     PageTitle = "Group: " + aGroup.Name;
     Members = aGroup.Members.ConvertAll<MemberVM>(aMember => new MemberVM(aMember, currentMember));
     RolesWithoutGlobal = aGroup.RolesWithoutGlobal;
     RolesWithGlobal = aGroup.RolesWithGlobal;
     RolesGloballyInherited = aGroup.RolesGloballyInherited;
     Articles = aGroup.Articles;
     Photos = aGroup.Photos;
     return true;
 }
Esempio n. 6
0
 public static bool Delete(IList<NumBitVM> model, ProviderCurrentMember currentMember)
 {
     bool returnStatus = true;
     foreach (NumBitVM pair in model)
     {
         if (pair.Bit && ProviderCategory.Exists(pair.Num))
         {
             ProviderCategory aCategory = new ProviderCategory(pair.Num);
             if (currentMember.CanEdit(aCategory))
             {
                 returnStatus &= aCategory.Delete();
             }
         }
     }
     InsideWordWebStaticCache.Instance.ClearCache();
     return returnStatus;
 }
Esempio n. 7
0
 public bool Save(ProviderCurrentMember currentMember)
 {
     if (!currentMember.IsNew)
     {
         ProviderArticle anArticle;
         List<long> tempList = new List<long>(ArticleIdList);
         foreach (long id in tempList)
         {
             anArticle = new ProviderArticle(id);
             // if the article already has a value then don't override or add a new one.
             if (!anArticle.MemberId.HasValue)
             {
                 anArticle.MemberId = currentMember.Id;
                 anArticle.Save();
             }
             ArticleIdList.Remove(id);
         }
     }
     return true;
 }
Esempio n. 8
0
        public static void AddComment(string textComment,
                                      ProviderCurrentMember currentMember,
                                      ProviderArticle anArticle ,
                                      ref ProviderConversation conversation,
                                      ref ProviderComment comment)
        {
            if (!currentMember.CanEdit(comment))
            {
                throw new Exception(ErrorStrings.OPERATION_NO_RIGHTS);
            }

            try
            {
                if (conversation.IsNew)
                {
                    conversation.MemberId = currentMember.Id;
                    conversation.ArticleId = anArticle.Id;
                    conversation.CreateDate = DateTime.UtcNow;
                }
                conversation.EditDate = DateTime.UtcNow;
                conversation.Save();

                //make sure the comment code is after the save since this
                //conversation doesn't exist yet.
                comment.ConversationId = conversation.Id.Value;
                comment.MemberId = currentMember.Id;
                comment.Text = textComment;
                comment.EditDate = DateTime.UtcNow;
                comment.CreateDate = DateTime.UtcNow;
                comment.IsHidden = false;
                comment.Save();
            }
            catch (Exception caughtException)
            {
                // DO NOT LOG THIS. It is the responsibility of the calling program to handle the exception
                throw new Exception("Failed to save comment", caughtException);
            }
        }
Esempio n. 9
0
 public static JqGridResponse Delete(EditCommentManagementVM model, ProviderCurrentMember currentMember)
 {
     JqGridResponse aResponse = new JqGridResponse();
     ProviderComment aComment = new ProviderComment(model.Id);
     if (currentMember.CanEdit(aComment))
     {
         if(aComment.Delete())
         {
             aResponse.Success = true;
         }
         else
         {
             aResponse.Success = false;
             aResponse.Message = ErrorStrings.OPERATION_FAILED;
         }
     }
     else
     {
         aResponse.Success = false;
         aResponse.Message = ErrorStrings.OPERATION_NO_RIGHTS;
     }
     return aResponse;
 }
Esempio n. 10
0
        public ProfileVM(ProviderMember aMember, ProviderCurrentMember currentMember, int page)
        {
            string userName = null;
            CurrentMember = new CurrentMemberVM(currentMember, aMember);

            if (CurrentMember.CanEdit)
            {
                userName = aMember.DisplayAdministrativeName;
            }
            else
            {
                userName = aMember.DisplayName;
            }

            int skip = page * BLURBS_PER_PAGE;
            if(skip > MAX_BLURBS)
            {
                ArticleList = new List<ArticleVM>();
            }
            else
            {
                bool? showPublished = true;
                if (CurrentMember.CanEdit)
                {
                    showPublished = null;
                }
                bool? showHidden = false;
                if (CurrentMember.CanEdit)
                {
                    showHidden = null;
                }
                ArticleList = ProviderArticle.LoadNewestBy(aMember, skip, BLURBS_PER_PAGE, showHidden, showPublished)
                                               .ConvertAll<ArticleVM>(anArticle => new ArticleVM(anArticle, currentMember));
            }
            IsLastPage = ArticleList.Count < BLURBS_PER_PAGE;
            NextPage = page + 1;

            if (aMember.HasValidAltId(ProviderAlternateMemberId.AlternateType.Domain))
            {
                ProviderDomain aDomain = aMember.Domains[0];
                HasWeb = true;
                WebUri = aDomain.Domain.AbsoluteUri;
                WebDisplay = IWStringUtility.TruncateClean(aDomain.DisplayName, ProviderMember.UserNameSize);
            }

            PageTitle = userName + " Profile";
            HeaderTitle = IWStringUtility.TruncateClean(userName, 28);
            Birthday = String.Format("{0:MMMM d, yyyy}", aMember.CreateDate);
            MemberId = aMember.Id;
            UserName = userName;
            ProfileImage = MemberBL.GetProfileImage(aMember);
            HasBio = !string.IsNullOrWhiteSpace(aMember.Bio);
            Bio = aMember.Bio;
        }
Esempio n. 11
0
        public AccountVM(ProviderMember aMember, ProviderCurrentMember currentMember)
        {
            Member = new MemberVM(aMember, currentMember);
            PageTitle = aMember.DisplayAdministrativeName + " Account";
            EmailAddresses = aMember.Emails.Select(email => email.Email.Address).ToList();
            OpenIds = aMember.OpenIds;

            ProfileImage = MemberBL.GetProfileImage(aMember);

            if (currentMember.CanEdit(aMember) && currentMember.HasAdminRights)
            {
                ArticleList = ProviderArticle.LoadBy(aMember.Id.Value, null, null).ConvertAll<ArticleVM>(anArticle => new ArticleVM(anArticle, currentMember));
            }
            else
            {
                ArticleList = ProviderArticle.LoadBy(aMember.Id.Value, null, false).ConvertAll<ArticleVM>(anArticle => new ArticleVM(anArticle, currentMember));
            }
            NoArticles = ArticleList.Count == 0;
            DisplayAlternateCategories = aMember.HasAlternateCategories && currentMember.HasAdminRights;
        }
Esempio n. 12
0
        public bool Parse(ProviderArticle anArticle, ProviderCurrentMember currentMember)
        {
            ProviderMember author = anArticle.Author;
            string authorName = null;
            long? authorId = null;
            if (author != null)
            {
                authorId = author.Id;
                authorName = author.DisplayName;
            }
            else
            {
                authorName = null;
            }

            bool authorIsNull = string.IsNullOrEmpty(authorName);
            PageTitle = anArticle.Title + " by " + (authorIsNull ? "Anonymous" : authorName);
            RelatedHeadlinesByCategory = anArticle.RelatedHeadlinesByCategory(5);
            RelatedHeadlinesByAuthor = anArticle.RelatedHeadlinesByAuthor(3);
            ConversationList = anArticle.Conversations.ConvertAll<ConversationVM>(aConversation => new ConversationVM(aConversation, currentMember, authorId));
            Article = new ArticleVM(anArticle, currentMember);

            return true;
        }
Esempio n. 13
0
 public DetailsVM(ProviderArticle anArticle, ProviderCurrentMember currentMember)
 {
     Parse(anArticle, currentMember);
 }
Esempio n. 14
0
 public GroupDetailVM(ProviderGroup aGroup, ProviderCurrentMember currentMember)
 {
     Parse(aGroup, currentMember);
 }
Esempio n. 15
0
 public GroupIndexVM(ProviderCurrentMember currentMember)
 {
     Parse(currentMember);
 }
Esempio n. 16
0
        public static bool Save(ArticleEditorVM model, ProviderArticle anArticle, ProviderCurrentMember currentMember, ref List<string> errorList)
        {
            bool returnValue = false;

            ProviderMember owningMember = GetArticleOwner(model, anArticle, currentMember);

            // IsNowClaimedArticle indicates if an article's state changed from unclaimed to now claimed
            bool IsNowClaimedArticle = anArticle.MemberId == null && owningMember.Id.HasValue;
            anArticle.MemberId = owningMember.Id;

            if (AssociatePhotos(model.ArticleBody, anArticle, ref errorList))
            {
                if (owningMember.IsActive && !currentMember.IsLoggedOn)
                {
                    // The owner is an active member but the current member is not logged in?! We're not sure if the member was lazy
                    // and didn't bother to login or if this is a malicious person, so we will set IsPublished to false and treat
                    // the article as a draft just to be safe.
                    anArticle.IsPublished = false;
                }
                else if (model.SaveState == ArticleEditorVM.SaveStates.Published)
                {
                    anArticle.IsPublished = true;
                }
                else if (model.SaveState == ArticleEditorVM.SaveStates.DraftAndContinue ||
                         model.SaveState == ArticleEditorVM.SaveStates.DraftAndPreview)
                {
                    anArticle.IsPublished = false;
                }
                else
                {
                    // defensive programming
                    anArticle.IsPublished = false;
                }

                anArticle.Title = model.Title;
                anArticle.Blurb = model.Blurb;
                anArticle.RawText = model.ArticleBody;

                if (anArticle.IsNew)
                {
                    anArticle.CreateDate = DateTime.UtcNow;
                }
                anArticle.EditDate = DateTime.UtcNow;

                // remove previous categories before adding new ones
                anArticle.RemoveAllCategories();
                anArticle.AddCategory(model.ArticleCategoryId);

                // important that we fetch this info before we save because then the article is no longer new.
                bool isNew = anArticle.IsNew;

                anArticle.Save();

                // if the current member is not logged on then save it in their workspace
                if (!currentMember.IsLoggedOn)
                {
                    currentMember.CurrentWorkSpace.ArticleIdList.Add(anArticle.Id.Value);
                }

                // Send out an e-mail for the article only if it was claimed for the first time through e-mail
                // and the member is not active
                if (IsNowClaimedArticle && !string.IsNullOrEmpty(model.ArticleEmail) && !currentMember.IsActive)
                {
                    EmailManager.Instance.SendEditArticleEmail(new MailAddress(model.ArticleEmail), anArticle, owningMember);
                }
                returnValue = true;
            }

            return returnValue;
        }
Esempio n. 17
0
        public static List<AlternateCategoryMapVM> MapCategories(ProviderCurrentMember currentMember, List<AlternateCategoryMapVM> memberToIWMap)
        {
            List<AlternateCategoryMapVM> IWToMemberMap = new List<AlternateCategoryMapVM>();
            ProviderCategory defaultCategory = new ProviderCategory(InsideWordSettingsDictionary.Instance.DefaultCategoryId.Value);
            List<ProviderAlternateCategoryId> alternateList = currentMember.AlternateCategoryList;
            List<ProviderCategory> iwCategoryList = ProviderCategory.LoadAll();
            ProviderAlternateCategoryId alternateCategory = null;
            ProviderCategory iwCategory = null;
            long? bestIWMatch = null;
            bool mapHasChanged = false;

            foreach (AlternateCategoryMapVM aMap in memberToIWMap)
            {
                mapHasChanged = false;
                alternateCategory = null;
                iwCategory = null;

                if (alternateList.Exists(altId => altId.AlternateId == aMap.AlternateId))
                {
                    // The alternate category is already in our system so just load it
                    alternateCategory = alternateList.Find(altId => altId.AlternateId == aMap.AlternateId);
                }
                else
                {
                    // The alternate category is not in our system so do a bit more work
                    alternateCategory = new ProviderAlternateCategoryId();
                    alternateCategory.MemberId = currentMember.Id.Value;
                    alternateCategory.AlternateId = aMap.AlternateId;
                }

                // ORDER OF "IF" STATEMENTS MATTERS HERE
                if (alternateCategory.OverrideFlag)
                {
                    // This is an override so use the server value
                    iwCategory = iwCategoryList.Find(aCategory => aCategory.Id == alternateCategory.CategoryId);
                }
                else if (aMap.MapId.HasValue && iwCategoryList.Exists(aCategory => aCategory.Id == aMap.MapId.Value))
                {
                    // the map is preset by the member so use that
                    iwCategory = iwCategoryList.Find(aCategory => aCategory.Id == aMap.MapId.Value);
                }
                else if (alternateCategory.CategoryId.HasValue)
                {
                    // the map is not preset by the member, but we have a server value so use the server value
                    iwCategory = iwCategoryList.Find(aCategory => aCategory.Id == alternateCategory.CategoryId);
                }
                else
                {
                    // this category map doesn't exist at all so find the best match
                    bestIWMatch = ProviderAlternateCategoryId.BestMatch(aMap.AlternateTitle);
                    if (bestIWMatch.HasValue)
                    {
                        iwCategory = iwCategoryList.Find(aCategory => aCategory.Id.Value == bestIWMatch.Value);
                    }
                    else if (iwCategoryList.Exists(aCategory => !aCategory.IsRoot &&
                                                                aCategory.Title
                                                                        .ToLowerInvariant()
                                                                        .CompareTo(aMap.AlternateTitle.ToLowerInvariant()) == 0))
                    {
                        iwCategory = iwCategoryList.Find(aCategory => aCategory.Title
                                                                        .ToLowerInvariant()
                                                                        .CompareTo(aMap.AlternateTitle.ToLowerInvariant()) == 0);
                    }
                    else
                    {
                        iwCategory = defaultCategory;
                    }
                }

                if (!alternateCategory.CategoryId.HasValue || alternateCategory.CategoryId.Value != iwCategory.Id.Value)
                {
                    alternateCategory.CategoryId = iwCategory.Id.Value;
                    mapHasChanged = true;
                }

                // finish and save the changes to the alternate category
                alternateCategory.OverrideFlag = false; // always reset the override flag here
                alternateCategory.DisplayName = aMap.AlternateTitle;
                alternateCategory.Save();

                IWToMemberMap.Add(new AlternateCategoryMapVM { AlternateTitle = iwCategory.Title, AlternateId = iwCategory.Id.Value, MapId = aMap.AlternateId });

                // determine if we need to refresh the articles on the server
                // Do this last to avoid race condition
                if (!alternateCategory.IsNew && mapHasChanged)
                {
                    // The category map changed. Re-categorize all articles related to this alternate category.
                    AsyncRefreshArticleManager.Instance.AddBy(AsyncRefreshArticleManager.LoadEnum.AltCategory, alternateCategory.Id.Value);
                }
            }

            return IWToMemberMap;
        }
Esempio n. 18
0
        public static bool UpdateAccount(ProviderCurrentMember currentMember, MemberDataVM data)
        {
            MailAddress validEmail;
            if (!string.IsNullOrWhiteSpace(data.Email) && IWStringUtility.TryParse(data.Email, out validEmail))
            {
                long? memberId = ProviderEmail.FindOwner(validEmail);

                // the e-mail has not been taken so we can take it
                if(!memberId.HasValue)
                {
                    List<ProviderEmail> emailList = currentMember.Emails;
                    if (!emailList.Exists(anEmail => anEmail.Email.Address == validEmail.Address))
                    {
                        // this e-mail doesn't exist so add it
                        ProviderEmail newEmail = new ProviderEmail();
                        newEmail.CreateDate = DateTime.UtcNow;
                        newEmail.EditDate = DateTime.UtcNow;
                        newEmail.Email = validEmail;
                        newEmail.IsValidated = false;
                        newEmail.MemberId = currentMember.Id.Value;
                        newEmail.Save();
                    }
                }
            }

            return true;
        }
Esempio n. 19
0
 public static JqGridResponse Delete(JqGridEditArticleVM model, ProviderCurrentMember currrentMember)
 {
     JqGridResponse aResponse = new JqGridResponse();
     ProviderArticle anArticle = new ProviderArticle(model.Id);
     if (currrentMember.CanEdit(anArticle))
     {
         if (anArticle.Delete())
         {
             aResponse.Success = true;
         }
         else
         {
             aResponse.Success = false;
             aResponse.Message = ErrorStrings.OPERATION_FAILED;
         }
     }
     else
     {
         aResponse.Success = false;
         aResponse.Message = ErrorStrings.OPERATION_NO_RIGHTS;
     }
     return aResponse;
 }
Esempio n. 20
0
 public bool Parse(ProviderCurrentMember currentMember)
 {
     return Parse(null, currentMember);
 }
Esempio n. 21
0
        /// <summary>
        /// Function to help determine the owner of an article. If sufficient information is
        /// provided and the owner does not exist in the system then they will be created.
        /// </summary>
        /// <param name="model">view model containing the data of the new article</param>
        /// <param name="currentMember">the current member using the site</param>
        /// <returns>Returns a ProviderMember who is the owner of the article</returns>
        public static ProviderMember GetArticleOwner(ArticleEditorVM model, ProviderArticle anArticle, ProviderCurrentMember currentMember)
        {
            ProviderMember owningMember;

            if (anArticle.MemberId.HasValue)
            {
                owningMember = new ProviderMember(anArticle.MemberId.Value);
            }
            else if (anArticle.IsNew || !string.IsNullOrEmpty(model.ArticleEmail))
            {
                // Have we been provided with an e-mail of the owner?
                if (!string.IsNullOrEmpty(model.ArticleEmail))
                {
                    MailAddress email = new MailAddress(model.ArticleEmail);
                    long? memberId = ProviderEmail.FindOwner(email, true);
                    if (memberId.HasValue)
                    {
                        // The owner already exists in our system so just retrieve them
                        owningMember = new ProviderMember(memberId.Value);
                    }
                    else
                    {
                        // the owner doesn't exists so create them
                        owningMember = new ProviderMember();
                        owningMember.CreateDate = DateTime.UtcNow;
                        owningMember.EditDate = DateTime.UtcNow;
                        owningMember.Save();

                        // attach the e-mail to this member
                        ProviderEmail anEmail = new ProviderEmail();
                        anEmail.MemberId = owningMember.Id.Value;
                        anEmail.IsValidated = false;
                        anEmail.CreateDate = DateTime.UtcNow;
                        anEmail.EditDate = DateTime.UtcNow;
                        anEmail.Email = email;
                        anEmail.Save();
                    }
                }
                else
                {
                    // no e-mail provided so just use whoever is currently logged on, whether they be anonymous or not
                    owningMember = currentMember;
                }
            }
            else
            {
                // this article has no owner so just return a blank member
                owningMember = new ProviderMember();
            }

            return owningMember;
        }
Esempio n. 22
0
 public bool Parse(ProviderMember aMember, ProviderCurrentMember currentMember)
 {
     AllGroups = ProviderGroup.LoadAll().ConvertAll<GroupVM>(aGroup => new GroupVM(aGroup, currentMember));
     if (aMember != null)
     {
         MemberGroups = aMember.Groups.ConvertAll<GroupVM>(aGroup => new GroupVM(aGroup, currentMember)); ;
     }
     return true;
 }
Esempio n. 23
0
        /// <summary>
        /// Function used to refresh the view model with any static data that may have been lost.
        /// This function is specifically used to refresh the model for a failed POST.
        /// </summary>
        /// <param name="anArticle">Article to refresh the data from</param>
        /// <param name="currentMember">Current member to refresh the data from</param>
        /// <param name="categoryList">Category list to refresh the data from</param>
        /// <returns>True if the function refreshed the model and false otherwise.</returns>
        public bool Refresh(ProviderArticle anArticle, ProviderCurrentMember currentMember, List<ProviderCategory> categoryList)
        {
            ArticleId = anArticle.Id;
            if (anArticle.IsNew)
            {
                PageTitle = "Publish Article";
            }
            else
            {
                PageTitle = "Edit Article: "+anArticle.Title;
            }

            // till the article has been associated with someone, keep showing the e-mail input
            ShowEmailInput = !anArticle.MemberId.HasValue;

            List<KeyValuePair<long, string>> ddList = new List<KeyValuePair<long, string>>();

            if (anArticle.CategoryIds.Count == 0)
            {
                ArticleCategoryId = -1;
                ddList.Add(_nullCategory);
            }
            else
            {
                ArticleCategoryId = anArticle.CategoryIds[0];
            }
            ddList.AddRange(categoryList.ToDictionary(aCategory => aCategory.Id.Value, aCategory => aCategory.Title));

            CategoryList = new SelectList(ddList, "key", "value", ArticleCategoryId);

            if (anArticle.IsPublished)
            {
                SaveState = SaveStates.Published;
            }
            else
            {
                SaveState = SaveStates.DraftAndContinue;
            }

            if (anArticle.CreateDate == DateTime.MinValue)
            {
                CreateDate = null;
                EditDate = null;
            }
            else
            {
                CreateDate = anArticle.CreateDate.ToShortDateString();
                EditDate = anArticle.EditDate.ToShortDateString();
            }

            return true;
        }
Esempio n. 24
0
 public MemberServerDataVM(ProviderCurrentMember currentMember, List<AlternateCategoryMapVM> map, ProviderCategory treeRoot)
 {
     StatusCode = (int)StatusEnum.success;
     Map = map;
     CategoryTree = new CategoryVM(treeRoot);
 }
Esempio n. 25
0
 public static JqGridResponse Process(EditCommentManagementVM model, ProviderCurrentMember currentMember)
 {
     JqGridResponse aResponse;
     if (model.Oper.CompareTo("edit") == 0)
     {
         aResponse = Edit(model, currentMember);
     }
     else if (model.Oper.CompareTo("del") == 0)
     {
         aResponse = Delete(model, currentMember);
     }
     else
     {
         aResponse = new JqGridResponse();
         aResponse.Success = false;
         aResponse.Message = ErrorStrings.OPERATION_UNKNOWN(model.Oper);
     }
     return aResponse;
 }
Esempio n. 26
0
 public GroupIndexVM(ProviderMember aMember, ProviderCurrentMember currentMember)
 {
     Parse(aMember, currentMember);
 }
Esempio n. 27
0
        public bool Parse(ProviderCurrentMember currentMember, List<ProviderCategory> categoryList)
        {
            PageTitle = "Publish Article";
            ShowEmailInput = !currentMember.IsLoggedOn;

            List<KeyValuePair<long, string>> ddList = new List<KeyValuePair<long, string>>();
            ddList.Add(_nullCategory);
            ddList.AddRange( categoryList.ToDictionary(aCategory => aCategory.Id.Value, aCategory => aCategory.Title) );
            ArticleCategoryId = -1;
            CategoryList = new SelectList(ddList, "key", "value", ArticleCategoryId);
            SaveState = SaveStates.DraftAndContinue;

            return true;
        }
Esempio n. 28
0
        public bool Parse(ProviderArticle anArticle, ProviderCurrentMember currentMember, List<ProviderCategory> categoryList)
        {
            ArticleBody = anArticle.RawText;
            if (!anArticle.BlurbIsAutoGenerated)
            {
                Blurb = anArticle.Blurb;
            }
            Title = anArticle.Title;

            Refresh(anArticle, currentMember, categoryList);

            return true;
        }
Esempio n. 29
0
        public static JqGridResponse Edit(JqGridEditArticleVM model, ProviderCurrentMember currentMember)
        {
            JqGridResponse aResponse = new JqGridResponse();
            ProviderArticle anArticle = new ProviderArticle(model.Id);
            if (currentMember.CanEdit(anArticle))
            {
                anArticle.IgnoreFlags = model.IgnoreFlags;
                anArticle.IsHidden = model.IsHidden;
                anArticle.IsPublished = model.IsPublished;
                try
                {
                    anArticle.Save();
                    aResponse.Success = true;
                }
                catch (Exception caughtException)
                {
                    aResponse.Success = false;
                    aResponse.Message = ErrorStrings.OPERATION_FAILED;
                }
            }
            else
            {
                aResponse.Success = false;
                aResponse.Message = ErrorStrings.OPERATION_NO_RIGHTS;
            }

            return aResponse;
        }