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; }
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; }
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; }
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; }
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); } }
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; }
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; }
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; }
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; }