public IEnumerable<IssueReplyModel> GetReplysToIssue(Issue anIssue, IEnumerable<string> aSelectedRoles, PersonFilter aFilter)
        {
            IEnumerable<IssueReplyDisposition> myIssueReplyDispositions = theEntities.IssueReplyDispositions;

            return (from ir in theEntities.IssueReplys.Include("IssueReplyComments")
                    join u in theEntities.Users on ir.User.Id equals u.Id
                    join ur in theEntities.UserRoles on u.Id equals ur.User.Id
                    join r in theEntities.Roles on ur.Role.Id equals r.Id
                    where ir.Issue.Id == anIssue.Id
                    && aSelectedRoles.Contains(r.Name)
                    && ir.Deleted == false
                    select new IssueReplyModel {
                        Id = ir.Id,
                        Issue = ir.Issue,
                        IssueStance = ir.Disposition,
                        User = u,
                        Reply = ir.Reply,
                        FirstName = ir.TempFirstName,
                        LastName = ir.TempLastName,
                        DateTimeStamp = ir.DateTimeStamp,
                        CommentCount = ir.IssueReplyComments.Where(cc => cc.Deleted == false).Count(),
                        HasDisposition = false,
                        TempDispositionHolder = ir.Disposition,
                        TempPersonFilterHolder = (int)aFilter,
                        TotalAgrees = (from d in ir.IssueReplyDispositions where ir.Disposition == (int)IssueStanceFilter.Agree select d).Count<IssueReplyDisposition>(),
                        TotalDisagrees = (from d in ir.IssueReplyDispositions where ir.Disposition == (int)IssueStanceFilter.Disagree select d).Count<IssueReplyDisposition>()
                    }).ToList<IssueReplyModel>();
        }
 public void DeleteIssue(User aDeletingUser, Issue anIssue, bool anAdminDelete)
 {
     anIssue.Deleted = true;
     anIssue.DeletedByUserId = aDeletingUser.Id;
     theEntities.ApplyCurrentValues(anIssue.EntityKey.EntitySetName, anIssue);
     theEntities.SaveChanges();
 }
        public Issue CreateIssue(Issue anIssueToCreate, User aUserCreating)
        {
            anIssueToCreate = Issue.CreateIssue(0, anIssueToCreate.Title, anIssueToCreate.Description, aUserCreating.City, aUserCreating.State, aUserCreating.Zip, DateTime.UtcNow, aUserCreating.Id, false);

            theEntities.AddToIssues(anIssueToCreate);
            theEntities.SaveChanges();

            return anIssueToCreate;
        }
Пример #4
0
        public static Issue CloneIssueWithReflection(Issue anIssue)
        {
            FieldInfo[] fields = anIssue.GetType().GetFields(System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.NonPublic);
            Issue newIssue = new Issue();
            foreach (FieldInfo field in fields) {
                field.SetValue(newIssue, field.GetValue(anIssue));
            }

            return newIssue;
        }
Пример #5
0
        public bool CreateIssue(UserInformationModel<User> aUserCreating, Issue aIssueToCreate)
        {
            if (!ValidateIssue(aIssueToCreate) || !IssueDoesntExist(aIssueToCreate.Title)) {
                return false;
            }

            if (!AllowedToPerformAction(aUserCreating, SocialPermission.Post_Issue)) {
                return false;
            }

            Issue myIssue = theIssueRepository.CreateIssue(aIssueToCreate, aUserCreating.Details);
            theIssueRepository.MarkIssueAsUnreadForAuthor(myIssue.Id);
            return true;
        }
Пример #6
0
        public IssueModel(Issue aIssue, IEnumerable<IssueReplyModel> aReplys)
        {
            this.Issue = aIssue;
            this.Replys = aReplys;
            this.Reply = string.Empty;
            this.Anonymous = false;
            this.Disposition = Disposition.None;
            TotalAgrees = (from d in Issue.IssueDispositions
                            where d.Disposition == (int)Disposition.Like
                            select d).Count<IssueDisposition>();

            TotalDisagrees = (from d in Issue.IssueDispositions
                                where d.Disposition == (int)Disposition.Dislike
                                select d).Count<IssueDisposition>();
        }
Пример #7
0
        private static TagBuilder EditDiv(UserInformationModel<User> myUserInformationModel, Issue anIssue, string aCssClass)
        {
            var myEditDiv = new TagBuilder("div");
            myEditDiv.MergeAttribute("class", aCssClass);

            if (IssueHelper.ShouldDisplayEditLink(myUserInformationModel, anIssue)) {
                var myEditLink = new TagBuilder("a");
                myEditLink.MergeAttribute("href", LinkHelper.EditIssue(anIssue));
                myEditLink.MergeAttribute("class", "edit");
                myEditLink.InnerHtml += "Edit";
                myEditDiv.InnerHtml += myEditLink.ToString();
            } else {
                myEditDiv.InnerHtml += "&nbsp;";
            }

            myEditDiv.InnerHtml += SharedStyleHelper.ClearDiv();
            return myEditDiv;
        }
Пример #8
0
 private static TagBuilder DisagreeDiv(UserInformationModel<User> aUserInformation, Issue anIssue, string aCssClass, SiteSection aSource, int aSourceId)
 {
     bool myHasDisposition = GetHasStance(anIssue, aUserInformation);
     bool myIsLoggedIn = aUserInformation != null;
     int myTotalDisagrees = GetTotalStance(anIssue, Disposition.Dislike);
     return SharedContentStyleHelper.DisagreeStanceDiv(aCssClass, myHasDisposition, myIsLoggedIn, myTotalDisagrees, LinkHelper.DisagreeIssue(anIssue.Id, aSource, aSourceId));
 }
Пример #9
0
        private static TagBuilder ComplaintDiv(UserInformationModel<User> myUserInformationModel, Issue anIssue, string aCssClass)
        {
            var myComplaintDiv = new TagBuilder("div");
            myComplaintDiv.MergeAttribute("class", aCssClass);

            if (myUserInformationModel != null) {
                myComplaintDiv.InnerHtml += ComplaintHelper.IssueLink(anIssue.Id);
            }

            myComplaintDiv.InnerHtml += SharedStyleHelper.ClearDiv();
            return myComplaintDiv;
        }
Пример #10
0
 public static string DeleteIssue(Issue anIssue)
 {
     return "/Issue/Delete/" + anIssue.Id;
 }
Пример #11
0
 private static bool ShouldDisplayEditLink(UserInformationModel<User> aUserInformation, Issue anIssue)
 {
     return (PermissionHelper<User>.AllowedToPerformAction(aUserInformation, SocialPermission.Edit_Issue) && aUserInformation.Details.Id == anIssue.UserId)
         || PermissionHelper<User>.AllowedToPerformAction(aUserInformation, SocialPermission.Edit_Any_Issue);
 }
 /// <summary>
 /// Deprecated Method for adding a new object to the Issues EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToIssues(Issue issue)
 {
     base.AddObject("Issues", issue);
 }
Пример #13
0
        private static string GetUserTypeForIssue(Issue anIssue)
        {
            string myType = "resident";
            foreach (UserRole myUserRole in anIssue.User.UserRoles.ToList<UserRole>()) {
                foreach (RolePermission myRolePermission in myUserRole.Role.RolePermissions) {
                    if(myRolePermission.Permission.Name.Equals(SocialPermission.Confirmed_Politician.ToString())) {
                        myType = "politician";
                        break;
                    } else if(myRolePermission.Permission.Name.Equals(SocialPermission.Confirmed_Political_Candidate.ToString())) {
                        myType = "candidate";
                        break;
                    }
                }
            }

            return myType;
        }
Пример #14
0
 private static bool GetHasStance(Issue anIssue, UserInformationModel<User> aUserInfoModel)
 {
     bool myHasDisposition =  aUserInfoModel != null &&
                             (from s in anIssue.IssueDispositions
                              where s.UserId == aUserInfoModel.Details.Id
                              select s).Count<IssueDisposition>() > 0 ? true : false;
     return myHasDisposition;
 }
 /// <summary>
 /// Create a new Issue object.
 /// </summary>
 /// <param name="id">Initial value of the Id property.</param>
 /// <param name="title">Initial value of the Title property.</param>
 /// <param name="description">Initial value of the Description property.</param>
 /// <param name="city">Initial value of the City property.</param>
 /// <param name="state">Initial value of the State property.</param>
 /// <param name="zip">Initial value of the Zip property.</param>
 /// <param name="dateTimeStamp">Initial value of the DateTimeStamp property.</param>
 /// <param name="userId">Initial value of the UserId property.</param>
 /// <param name="deleted">Initial value of the Deleted property.</param>
 public static Issue CreateIssue(global::System.Int32 id, global::System.String title, global::System.String description, global::System.String city, global::System.String state, global::System.Int32 zip, global::System.DateTime dateTimeStamp, global::System.Int32 userId, global::System.Boolean deleted)
 {
     Issue issue = new Issue();
     issue.Id = id;
     issue.Title = title;
     issue.Description = description;
     issue.City = city;
     issue.State = state;
     issue.Zip = zip;
     issue.DateTimeStamp = dateTimeStamp;
     issue.UserId = userId;
     issue.Deleted = deleted;
     return issue;
 }
 public void UpdateIssue(User aUser, Issue anOriginal, Issue aNew, bool anOverride)
 {
     string myOldTitle = anOriginal.Title;
     string myOldDescription = anOriginal.Description;
     AuditIssue myAUdit = AuditIssue.CreateAuditIssue(0, anOriginal.Id, myOldTitle, myOldDescription, DateTime.UtcNow, aUser.Id);
     anOriginal.Title = aNew.Title;
     anOriginal.Description = aNew.Description;
     anOriginal.UpdatedDateTimeStamp = DateTime.UtcNow;
     anOriginal.UpdatedByUserId = aUser.Id;
     theEntities.AddToAuditIssues(myAUdit);
     theEntities.ApplyCurrentValues(anOriginal.EntityKey.EntitySetName, anOriginal);
     theEntities.SaveChanges();
 }
        public void MarkIssueAsReadForAuthor(Issue anIssue)
        {
            IssueViewedState myIssueViewedState = GetIssueViewedState(anIssue.Id, anIssue.UserId);
            myIssueViewedState.Viewed = true;

            theEntities.SaveChanges();
        }
Пример #18
0
 private static int GetTotalStance(Issue anIssue, Disposition aStance)
 {
     return (from s in anIssue.IssueDispositions
             where s.Disposition == (int)aStance
             select s).Count<IssueDisposition>();
 }
Пример #19
0
        public bool EditIssue(UserInformationModel<User> aUserEditing, Issue anIssue)
        {
            if (!ValidateIssue(anIssue)) {
                return false;
            }

            if (!AllowedToPerformAction(aUserEditing, SocialPermission.Edit_Issue, SocialPermission.Edit_Any_Issue)) {
                return false;
            }

            bool myOverride = PermissionHelper<User>.AllowedToPerformAction(aUserEditing, SocialPermission.Edit_Any_Issue);
            Issue myOriginalIssue = GetIssue(anIssue.Id, aUserEditing);

            if (myOriginalIssue.User.Id == aUserEditing.Details.Id || myOverride) {
                if (!myOriginalIssue.Title.Equals(anIssue.Title) && !IssueDoesntExist(anIssue.Title)) {
                    return false;
                }
                theIssueRepository.UpdateIssue(aUserEditing.Details, myOriginalIssue, anIssue, myOverride);
                return true;
            } else {
                theValidationDictionary.AddError("PerformAction", string.Empty, "You are not allowed to edit the issue.");
            }

            return false;
        }
Пример #20
0
        private static string IssueInformationDiv(Issue anIssue, bool anAnonymous, UserInformationModel<User> aUserInfoModel, bool aHasStance, string anIssueInfoCssClass, string anEditAndStanceCssClass, string aReportCssClass, string anAgreeCssClass,
                                                 string aDisagreeCssClass, string anDeleteCssClass, string anEditCssClass, SiteSection aSiteSection, int aSourceId)
        {
            var myIssueInfoDiv = new TagBuilder("div");
            myIssueInfoDiv.AddCssClass(anIssueInfoCssClass);

            var myIssueInfoPadding = new TagBuilder("div");
            myIssueInfoPadding.AddCssClass("p-a10");
            myIssueInfoPadding.InnerHtml += SharedStyleHelper.InfoSpeakSpan("speak-lft");

            var myHeadTitle = new TagBuilder("h1");
            var myIssueLink = new TagBuilder("a");
            myIssueLink.MergeAttribute("href", LinkHelper.IssueUrl(anIssue.Title));
            myIssueLink.InnerHtml = anIssue.Title;
            myHeadTitle.InnerHtml += myIssueLink.ToString();

            string myName = NameHelper.FullName(anIssue.User);
            string myProfileLink = LinkHelper.Profile(anIssue.User);
            if (anAnonymous) {
                myName = HAVConstants.ANONYMOUS;
                myProfileLink = "#";
            }

            var myNameLink = new TagBuilder("a");
            myNameLink.AddCssClass("name-2");
            myNameLink.MergeAttribute("href", myProfileLink);
            myNameLink.InnerHtml = myName;

            var myLocationSpan = new TagBuilder("span");
            myLocationSpan.AddCssClass("loc c-white");
            myLocationSpan.InnerHtml = anIssue.City + ", " + anIssue.State;

            string myUserType = GetUserTypeForIssue(anIssue);
            var myIconSpan = new TagBuilder("span");
            myIconSpan.AddCssClass(myUserType);
            myIconSpan.MergeAttribute("title", myUserType);
            myIconSpan.InnerHtml = "&nbsp;";

            myIssueInfoPadding.InnerHtml += myHeadTitle.ToString();
            myIssueInfoPadding.InnerHtml += myNameLink.ToString();
            myIssueInfoPadding.InnerHtml += "&nbsp;";
            myIssueInfoPadding.InnerHtml += myLocationSpan.ToString();
            myIssueInfoPadding.InnerHtml += "&nbsp;";
            myIssueInfoPadding.InnerHtml += myIconSpan.ToString();
            myIssueInfoPadding.InnerHtml += new TagBuilder("br").ToString();
            myIssueInfoPadding.InnerHtml += PresentationHelper.ReplaceCarriageReturnWithBR(anIssue.Description);

            myIssueInfoPadding.InnerHtml += SharedStyleHelper.ClearDiv();

            var myEditAndStanceDiv = new TagBuilder("div");
            myEditAndStanceDiv.AddCssClass(anEditAndStanceCssClass);
            myEditAndStanceDiv.InnerHtml += SharedStyleHelper.StyledHtmlDiv(aReportCssClass, ComplaintHelper.IssueLink(anIssue.Id)).ToString();
            myEditAndStanceDiv.InnerHtml += DeleteDiv(aUserInfoModel, anIssue, anDeleteCssClass);
            myEditAndStanceDiv.InnerHtml += EditDiv(aUserInfoModel, anIssue, anEditCssClass);
            if (anAgreeCssClass != string.Empty) {
                myEditAndStanceDiv.InnerHtml += AgreeDiv(aUserInfoModel, anIssue, anAgreeCssClass, aSiteSection, aSourceId);
            }
            if (aDisagreeCssClass != string.Empty) {
                myEditAndStanceDiv.InnerHtml += DisagreeDiv(aUserInfoModel, anIssue, aDisagreeCssClass, aSiteSection, aSourceId);
            }
            myEditAndStanceDiv.InnerHtml += SharedStyleHelper.ClearDiv();

            myIssueInfoPadding.InnerHtml += myEditAndStanceDiv.ToString();

            myIssueInfoDiv.InnerHtml += myIssueInfoPadding.ToString();
            return myIssueInfoDiv.ToString();
        }
Пример #21
0
        private IssueModel FillIssueModel(User myViewingUser, Issue anIssue)
        {
            if (anIssue == null) {
                return null;
            }

            IEnumerable<IssueReplyModel> myPeopleReplys = new List<IssueReplyModel>();
            IEnumerable<IssueReplyModel> myPoliticianReplys = new List<IssueReplyModel>();
            IEnumerable<IssueReplyModel> myPoliticalCandidateReplys = new List<IssueReplyModel>();

            if (myViewingUser == null) {
                myPeopleReplys = theIssueReplyRepository.GetReplysToIssue(anIssue, UserRoleHelper.RegisteredRoles(), PersonFilter.People);
                myPoliticianReplys = theIssueReplyRepository.GetReplysToIssue(anIssue, UserRoleHelper.PoliticianRoles(), PersonFilter.Politicians);
                myPoliticalCandidateReplys = theIssueReplyRepository.GetReplysToIssue(anIssue, UserRoleHelper.PoliticalCandidateRoles(), PersonFilter.PoliticalCandidates);
            } else {
                myPeopleReplys = theIssueReplyRepository.GetReplysToIssue(myViewingUser, anIssue, UserRoleHelper.RegisteredRoles(), PersonFilter.People);
                myPoliticianReplys = theIssueReplyRepository.GetReplysToIssue(myViewingUser, anIssue, UserRoleHelper.PoliticianRoles(), PersonFilter.Politicians);
                myPoliticalCandidateReplys = theIssueReplyRepository.GetReplysToIssue(myViewingUser, anIssue, UserRoleHelper.PoliticalCandidateRoles(), PersonFilter.PoliticalCandidates);
            }

            List<IssueReplyModel> myMerged = new List<IssueReplyModel>();
            myMerged.AddRange(myPeopleReplys);
            myMerged.AddRange(myPoliticianReplys);
            myMerged.AddRange(myPoliticalCandidateReplys);

            myMerged = myMerged.OrderByDescending(i => i.DateTimeStamp).ToList<IssueReplyModel>();

            return new IssueModel(anIssue, myMerged);
        }
Пример #22
0
        public static string IssueInformationDiv(Issue anIssue, bool anIsAnonymous, string anIssueInfoCssClass, string anEditAndStanceCssClass, string aReportCssClass, string anAgreeCssClass,
                                                 string aDisagreeCssClass, string aDeleteCssClass, string anEditCssClass, string anAlternateStanceDeleteCssClass, string anAlternateStanceEditCssClass, bool aUseAlternate,
                                                 SiteSection aSiteSection, int aSourceId)
        {
            string myAgreeCssClass = anAgreeCssClass;
            string myDisagreeCssClass = aDisagreeCssClass;
            string myDeleteCssClass = aDeleteCssClass;
            string myEditCssClass = anEditCssClass;
            UserInformationModel<User> myUserInfo = HAVUserInformationFactory.GetUserInformation();
            bool myHasStance = GetHasStance(anIssue, myUserInfo);

            if (aUseAlternate && (myHasStance || myUserInfo == null)) {
                myAgreeCssClass = string.Empty;
                myDisagreeCssClass = string.Empty;
                myDeleteCssClass = anAlternateStanceDeleteCssClass;
                myEditCssClass = anAlternateStanceEditCssClass;
            }
            return IssueInformationDiv(anIssue, anIsAnonymous, myUserInfo, myHasStance, anIssueInfoCssClass, anEditAndStanceCssClass, aReportCssClass, myAgreeCssClass,
                myDisagreeCssClass, myDeleteCssClass, myEditCssClass, aSiteSection, aSourceId);
        }
Пример #23
0
        private bool ValidateIssue(Issue aIssueToValidate)
        {
            if (aIssueToValidate.Title.Trim().Length == 0) {
                theValidationDictionary.AddError("Title", aIssueToValidate.Title, "Title is required.");
            } else if (!VarCharValidation.Valid100Length(aIssueToValidate.Title)) {
                theValidationDictionary.AddError("Title", aIssueToValidate.Title, "The issue title is too long.");
            } else {
                Regex myRegex = new Regex(RegexHelper.IssueTitleRegex(), RegexOptions.IgnoreCase);
                Match myMatch = myRegex.Match(aIssueToValidate.Title);
                if (!myMatch.Success || aIssueToValidate.Title.Contains('_') || aIssueToValidate.Title.Contains('?') || aIssueToValidate.Title.Contains('"')) {
                    theValidationDictionary.AddError("Title", aIssueToValidate.Title, "The issue title can only be letters, numbers, and the following special characters: , - . ; !'");
                }
            }

            if (aIssueToValidate.Description.Trim().Length == 0) {
                theValidationDictionary.AddError("Description", aIssueToValidate.Description, "Description is required.");
            }

            return theValidationDictionary.isValid;
        }
Пример #24
0
 public static string ReportIssue(Issue anIssue)
 {
     return "/Complaint/Complaint?sourceId=" + anIssue.Id + "&complaintType=Issue";
 }
Пример #25
0
        public static string IssueStats(Issue anIssue, string aDivCssClass, string aDivPaddingCssClass, string aStatsHeading, 
                                        string aStatsHeadingCssClass, string aPostedCssClass, string aDateTimeCssClass,
                                        string aAgreeCssClass, string aDisagreeCssClass, string aStanceLabelSpanCssClass, string aDateTimeFormat)
        {
            var myStatsDiv = new TagBuilder("div");
            myStatsDiv.AddCssClass(aDivCssClass);

            var myStatsPadding = new TagBuilder("div");
            myStatsPadding.AddCssClass(aDivPaddingCssClass);

            var myStatsHeading = new TagBuilder(aStatsHeading);
            myStatsHeading.AddCssClass(aStatsHeadingCssClass);
            myStatsHeading.InnerHtml = "Stats";

            var myPostedDiv = new TagBuilder("div");
            myPostedDiv.AddCssClass(aPostedCssClass);
            myPostedDiv.InnerHtml = "Posted:";

            var myDateTimeStampDiv = new TagBuilder("div");
            myDateTimeStampDiv.AddCssClass(aDateTimeCssClass);
            myDateTimeStampDiv.InnerHtml += anIssue.DateTimeStamp.ToString(aDateTimeFormat).ToUpper();

            var myStanceSpanLabel = new TagBuilder("span");
            myStanceSpanLabel.AddCssClass(aStanceLabelSpanCssClass);

            var myAgreesDiv = new TagBuilder("div");
            myAgreesDiv.AddCssClass(aAgreeCssClass);
            myStanceSpanLabel.InnerHtml = "Agrees: ";
            myAgreesDiv.InnerHtml += myStanceSpanLabel.ToString();
            myAgreesDiv.InnerHtml += GetTotalStance(anIssue, Disposition.Like);

            var myDisagreeDiv = new TagBuilder("div");
            myDisagreeDiv.AddCssClass(aDisagreeCssClass);
            myStanceSpanLabel.InnerHtml = "Disagrees: ";
            myDisagreeDiv.InnerHtml += myStanceSpanLabel.ToString();
            myDisagreeDiv.InnerHtml += GetTotalStance(anIssue, Disposition.Dislike);

            myStatsPadding.InnerHtml += myStatsHeading.ToString();
            myStatsPadding.InnerHtml += myPostedDiv.ToString();
            myStatsPadding.InnerHtml += myDateTimeStampDiv.ToString();
            myStatsPadding.InnerHtml += myAgreesDiv.ToString();
            myStatsPadding.InnerHtml += myDisagreeDiv.ToString();

            myStatsDiv.InnerHtml += SharedStyleHelper.ClearDiv();
            myStatsDiv.InnerHtml += myStatsPadding.ToString();

            return myStatsDiv.ToString();
        }
Пример #26
0
 public static string EditIssue(Issue anIssue)
 {
     return "/Issue/Edit/" + anIssue.Id;
 }
        private void CreateEmailJobForAuthorOfIssueWithoutSave(Issue anIssue)
        {
            string mySubject = EmailContent.NewReplySubject(anIssue);
            string myBody = EmailContent.NewReplyBody(anIssue);

            EmailJob myEmailJob =
                EmailJob.CreateEmailJob(0, EmailType.REPLY_TO_ISSUE.ToString(), SiteConfiguration.NotificationsEmail(),
                anIssue.User.Email, mySubject, myBody, DateTime.UtcNow, false, false);
            theEntities.AddToEmailJobs(myEmailJob);
        }