public IEnumerable<IssueViewedState> UnreadIssues(User aUser)
 {
     return (from v in theEntities.IssueViewedStates
             where v.UserId == aUser.Id
             && v.Viewed == false
             select v).ToList<IssueViewedState>();
 }
 public PetitionSignature GetPetitionSignature(User aUser, int aPetitionId)
 {
     return (from s in theEntities.PetitionSignatures
             where s.PetitionId == aPetitionId
             && s.UserId == aUser.Id
             select s).FirstOrDefault<PetitionSignature>();
 }
        public void AddPhotoComplaint(User aFiledBy, string aComplaint, int aPictureId)
        {
            PhotoComplaint myPhotoComplaint = PhotoComplaint.CreatePhotoComplaint(0, aFiledBy.Id, aPictureId, aComplaint);

            theEntities.AddToPhotoComplaints(myPhotoComplaint);
            theEntities.SaveChanges();
        }
        public void AddIssueReplyComplaint(User aFiledBy, string aComplaint, int anIssueReplyId)
        {
            IssueReplyComplaint myIssueReplyComplaint = IssueReplyComplaint.CreateIssueReplyComplaint(0, aFiledBy.Id, anIssueReplyId, aComplaint);

            theEntities.AddToIssueReplyComplaints(myIssueReplyComplaint);
            theEntities.SaveChanges();
        }
 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 void AddProfileComplaint(User aFiledBy, string aComplaint, int aTowardUserId)
        {
            ProfileComplaint myProfileComplaint = ProfileComplaint.CreateProfileComplaint(0, aFiledBy.Id, aTowardUserId, aComplaint);

            theEntities.AddToProfileComplaints(myProfileComplaint);
            theEntities.SaveChanges();
        }
 public void CreateTokenForEmail(User aCreatingUser, string anEmail, string aToken, string anAuthorityType, string anAuthorityPosition)
 {
     Role myRole = GetRoleByName(anAuthorityType);
     AuthorityVerification myVerification = AuthorityVerification.CreateAuthorityVerification(anEmail, aCreatingUser.Id, myRole.Id, aToken, false, DateTime.UtcNow, anAuthorityPosition);
     theEntities.AddToAuthorityVerifications(myVerification);
     theEntities.SaveChanges();
 }
        public IEnumerable<FriendConnectionModel> FindUsersBasedOnQuestion(User aUser, IEnumerable<string> aQuestionNames)
        {
            Dictionary<string, int> myQuestionToAnswers = new Dictionary<string, int>();
            foreach (string myQuestionName in aQuestionNames) {
                UserProfileQuestionAnswer myAnswer = GetProfileQuesitonAnswerForUser(aUser, myQuestionName);
                if (myAnswer != null) {
                    myQuestionToAnswers.Add(myQuestionName, myAnswer.Answer);
                }
            }

            if (myQuestionToAnswers.Keys.Count == 0) {
                return new List<FriendConnectionModel>();
            } else {
                List<FriendConnectionModel> myFriendConnections = new List<FriendConnectionModel>();

                foreach(string myQuestionName in aQuestionNames) {
                    if (myQuestionToAnswers.Keys.Contains(myQuestionName)) {
                        int myAnswer = myQuestionToAnswers[myQuestionName];
                        IEnumerable<FriendConnectionModel> myResults = (from a in theEntities.UserProfileQuestionAnswers
                                                                        where a.UserProfileQuestionName == myQuestionName
                                                                        && a.Answer == myAnswer
                                                                        && a.UserId != aUser.Id
                                                                        select new FriendConnectionModel() {
                                                                            User = a.User,
                                                                            QuestionConnectionMadeFrom = a.UserProfileQuestion
                                                                        });
                        myFriendConnections.AddRange(myResults);
                    }
                }

                return myFriendConnections;
            }
        }
 public Petition CreatePetition(User aUserCreating, string aTitle, string aBody, string aCity, string aState, string aZip)
 {
     Petition myPetition = Petition.CreatePetition(0, aUserCreating.Id, aTitle, aBody, aCity, aState, aZip, DateTime.UtcNow, true);
     theEntities.AddToPetitions(myPetition);
     theEntities.SaveChanges();
     return myPetition;
 }
        public int NewMessageCount(User aRequestingUser)
        {
            int myTotalUnreadReceived = theNavRepo.GetUnreadMessagesReceivedCount(aRequestingUser);
            int myTotalUnreadSent = theNavRepo.GetUnreadMessagesSentCount(aRequestingUser);

            return myTotalUnreadReceived + myTotalUnreadSent;
        }
 public IEnumerable<GroupInvitation> GroupInvitations(User aUser)
 {
     return (from i in theEntities.GroupInvitations
             where i.UserId == aUser.Id
             && i.Viewed == false
             && i.Accepted == HAVConstants.PENDING
             select i);
 }
 public void ActivateGroup(User aUser, int aGroupId)
 {
     Group myClub = GetGroup(aGroupId);
     myClub.DeactivatedByUserId = null;
     myClub.DeactivatedDateTimeStamp = null;
     myClub.Active = true;
     theEntities.SaveChanges();
 }
Exemplo n.º 13
0
 public bool ProfileComplaint(User aFiledBy, string aComplaint, int aTowardUserId)
 {
     if (!ValidComplaint(aComplaint, aTowardUserId)) {
         return false;
     }
     theRepository.AddProfileComplaint(aFiledBy, aComplaint, aTowardUserId);
     return true;
 }
 public void SetPetitionAsInactive(User aUser, int aPetitionId)
 {
     Petition myPetition = GetPetition(aPetitionId);
     myPetition.Active = false;
     myPetition.DeactivatedByUserId = aUser.Id;
     myPetition.DeactivatedDateTimeStamp = DateTime.UtcNow;
     theEntities.SaveChanges();
 }
Exemplo n.º 15
0
 public bool IssueReplyComplaint(User aFiledBy, string aComplaint, int aIssueReplyId)
 {
     if (!ValidComplaint(aComplaint, aIssueReplyId)) {
         return false;
     }
     theRepository.AddIssueReplyComplaint(aFiledBy, aComplaint, aIssueReplyId);
     return true;
 }
        public void AddIssueReplyCommentComplaint(User aFiledBy, string aComplaint, int anIssueReplyCommentId)
        {
            IHAVIssueRepository myIssueRepo = new EntityHAVIssueRepository();
            IssueReplyCommentComplaint issueReplyCommentComplaint = IssueReplyCommentComplaint.CreateIssueReplyCommentComplaint(0, aFiledBy.Id, anIssueReplyCommentId, aComplaint);

            theEntities.AddToIssueReplyCommentComplaints(issueReplyCommentComplaint);
            theEntities.SaveChanges();
        }
Exemplo n.º 17
0
 public bool AddFeedback(User aUser, string aFeedback)
 {
     if (!ValidFeedback(aFeedback)) {
         return false;
     }
     theRepository.AddFeedback(aUser, aFeedback);
     return true;
 }
 public UserRegionSpecific GetRegionSpecifcInformationForUser(User aUser, UserPosition aUserPosition)
 {
     return (from urs in theEntities.UserRegionSpecifics
             join rs in theEntities.RegionSpecifics on urs.RegionSpecificId equals rs.Id
             where urs.UserId == aUser.Id
             && rs.UserPositionId == aUserPosition.Position
             select urs).FirstOrDefault<UserRegionSpecific>();
 }
Exemplo n.º 19
0
 public bool PhotoComplaint(User aFiledBy, string aComplaint, int aPhotoId)
 {
     if (!ValidComplaint(aComplaint, aPhotoId)) {
         return false;
     }
     theRepository.AddPhotoComplaint(aFiledBy, aComplaint, aPhotoId);
     return true;
 }
        public Event AddEvent(User aUser, DateTime aStartDate, DateTime anEndDate, string aTitle, string anInformation)
        {
            IUserRepository<User, Role, UserRole> myUserRepo = new EntityHAVUserRepository();
            Event myEvent = Event.CreateEvent(0, aUser.Id, aStartDate, anEndDate , aTitle, anInformation, false);
            theEntities.AddToEvents(myEvent);
            theEntities.SaveChanges();

            return myEvent;
        }
 public void AddUserToIgnoreList(User aUser, int aUserIdToIgnore)
 {
     FriendSuggestionIgnore myFriendSuggestion = GetFriendSuggestionIgnore(aUser, aUserIdToIgnore);
     if (myFriendSuggestion == null) {
         FriendSuggestionIgnore myIgnore = FriendSuggestionIgnore.CreateFriendSuggestionIgnore(0, aUser.Id, aUserIdToIgnore);
         theEntities.AddToFriendSuggestionIgnores(myIgnore);
         theEntities.SaveChanges();
     }
 }
Exemplo n.º 22
0
 public bool AddIssueStance(User aUser, int anIssueId, int aDisposition)
 {
     if (theIssueRepository.HasIssueStance(aUser, anIssueId)) {
         return false;
     } else {
         theIssueRepository.CreateIssueStance(aUser, anIssueId, aDisposition);
         return true;
     }
 }
        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;
        }
        public void CreateCommentToIssueReply(User aUserCreating, int anIssueReplyId, string aComment)
        {
            IssueReplyComment myIssueReplyComment = IssueReplyComment.CreateIssueReplyComment(0, anIssueReplyId, aComment, DateTime.UtcNow, aUserCreating.Id, false);
            theEntities.AddToIssueReplyComments(myIssueReplyComment);

            IssueReplyViewedHelper.UpdateCurrentIssueReplyViewedStateAndAddIfNecessaryWithoutSave(theEntities, aUserCreating.Id, anIssueReplyId);

            theEntities.SaveChanges();
        }
 public IEnumerable<Board> UnreadBoardMessages(User aUser)
 {
     return (from b in theEntities.Boards
             join v in theEntities.BoardViewedStates on b.Id equals v.BoardId
             where v.Viewed == false
             && b.OwnerUserId == aUser.Id
             && v.UserId == aUser.Id
             select b).ToList<Board>();
 }
 public IEnumerable<GroupMember> UnreadGroupBoardPosts(User aUser)
 {
     return (from gm in theEntities.GroupMembers
             where gm.MemberUserId == aUser.Id
             && !gm.Deleted
             && !gm.OldRecord
             && !gm.BoardViewed
             select gm);
 }
 public IEnumerable<IssueReplyViewedState> UnreadIssueReplies(User aUser)
 {
     return (from v in theEntities.IssueReplyViewedStates
             join ir in theEntities.IssueReplys on v.IssueReplyId equals ir.Id
             where v.Viewed == false
             && v.UserId == aUser.Id
             && ir.UserId == aUser.Id
             select v).ToList<IssueReplyViewedState>();
 }
 public IEnumerable<BoardViewedState> UnreadParticipatingBoardMessages(User aUser)
 {
     return (from v in theEntities.BoardViewedStates
             join b in theEntities.Boards on v.BoardId equals b.Id
             where v.Viewed == false
             && v.UserId == aUser.Id
             && b.OwnerUserId != aUser.Id
             select v).ToList<BoardViewedState>();
 }
 public void DeleteEvent(User aUser, int anEventId, bool anAdminDelete)
 {
     Event myEvent = GetEvent(anEventId);
     if (myEvent.User.Id == aUser.Id || anAdminDelete) {
         myEvent.Deleted = true;
         myEvent.DeletedUserId = aUser.Id;
         theEntities.ApplyCurrentValues(myEvent.EntityKey.EntitySetName, myEvent);
         theEntities.SaveChanges();
     }
 }
        public void AddZipCodesForUser(User anAdminUser, string anEmail, IEnumerable<int> aZipCodes)
        {
            User myAuthority = GetUser(anEmail);

            foreach(int myZipCode in aZipCodes) {
                AuthorityViewableZipCode myAuthorityZipCode = AuthorityViewableZipCode.CreateAuthorityViewableZipCode(0, myAuthority.Id, myZipCode, anAdminUser.Id, DateTime.UtcNow);
                theEntities.AddToAuthorityViewableZipCodes(myAuthorityZipCode);
            }

            theEntities.SaveChanges();
        }