public virtual JsonResult ChangeArticleState(long articleId, InsideWordProvider.ProviderArticle.ArticleState state) { string from = "APILOGINFO - " + HttpContext.Request.UserHostAddress; InsideWordWebLog.Instance.Buffer(from, "ChangeArticleState(" + articleId + ", " + state.ToString() + ")"); ApiMsgVM returnMessage = new ApiMsgVM( (int)ApiMsgVM.StatusEnum.failure ); ProviderCurrentMember currentMember = ProviderCurrentMember.Instance; ProviderArticle anArticle = new ProviderArticle(); if (!currentMember.IsLoggedOn) { returnMessage.StatusCode = (int)ApiMsgVM.StatusEnum.failure; returnMessage.StatusMessage = "You must be logged in to use this command. Use the API function " + Url.Action(MVC.API.Login()) + " to login."; } else if (!anArticle.Load(articleId)) { returnMessage.StatusCode = (int)ApiMsgVM.StatusEnum.failure; returnMessage.StatusMessage = "Could not change status. No article with id "+articleId; returnMessage.Content = String.Empty; } else if (!currentMember.CanEdit(anArticle)) { returnMessage.StatusCode = (int)ApiMsgVM.StatusEnum.failure; returnMessage.StatusMessage = "Could not change status. Member does not have the rights to edit article " + articleId; returnMessage.Content = String.Empty; } else { bool returnMessageIsSet = false; anArticle.EditDate = DateTime.UtcNow; switch (state) { case ProviderArticle.ArticleState.delete: anArticle.IsHidden = true; anArticle.IsPublished = false; anArticle.Save(); break; case ProviderArticle.ArticleState.flagged: anArticle.IsHidden = true; anArticle.IsPublished = false; anArticle.Save(); break; case ProviderArticle.ArticleState.hidden: anArticle.IsHidden = true; anArticle.IsPublished = false; anArticle.Save(); break; case ProviderArticle.ArticleState.draft: anArticle.IsPublished = false; anArticle.Save(); break; case ProviderArticle.ArticleState.publish: anArticle.IsPublished = true; anArticle.Save(); break; default: returnMessageIsSet = true; returnMessage.StatusCode = (int)ApiMsgVM.StatusEnum.failure; returnMessage.StatusMessage = "Unknown status update "+state+" for article."; returnMessage.Content = String.Empty; break; } if (!returnMessageIsSet) { returnMessage.StatusCode = (int)ApiMsgVM.StatusEnum.success; returnMessage.StatusMessage = "Successfully updated article " + articleId + " status'."; returnMessage.Content = String.Empty; } } InsideWordWebLog.Instance.Buffer(from, "Done ChangeArticleState - " + returnMessage); return Json(returnMessage); }
public static void Parse(ObjectTypeElement anElement, InsideWordProvider.ProviderPermission.ObjectTypeData objectTypeData) { objectTypeData.AddObjectTypeData(Type.GetType(anElement.ObjectType), anElement.DisplayName, anElement.Id); }
public override System.Web.Mvc.JsonResult ChangeArticleState(long articleId, InsideWordProvider.ProviderArticle.ArticleState state) { var callInfo = new T4MVC_JsonResult(Area, Name, ActionNames.ChangeArticleState); callInfo.RouteValueDictionary.Add("articleId", articleId); callInfo.RouteValueDictionary.Add("state", state); return callInfo; }