コード例 #1
0
        public void CanUpdateTag()
        {
            TagTypeRepository repoTagtypes    = new TagTypeRepository();
            TagType           tagTypeOriginal = new TagType
            {
                Description = "tag type original"
            };
            TagType tagTypeUpdated = new TagType
            {
                Description = "tag type updated"
            };

            repoTagtypes.Add(tagTypeOriginal);
            repoTagtypes.Add(tagTypeUpdated);

            TagRepository repoTags = new TagRepository();
            Tag           tag      = new Tag
            {
                Description = "tag",
                TagType     = tagTypeOriginal
            };

            repoTags.Add(tag);

            tag.Description = "tag updated";
            tag.TagType     = tagTypeUpdated;
            repoTags.Update(tag);

            Assert.AreEqual(tag, repoTags.GetById(tag.Id));
        }
コード例 #2
0
ファイル: UnitOfWork.cs プロジェクト: lodeane94/JAProperties
 public UnitOfWork(EasyFindPropertiesEntities dbCtx)
 {
     _dbCtx              = dbCtx;
     PropertyType        = new PropertyTypeRepository(_dbCtx);
     AdPriority          = new AdPriorityRepository(_dbCtx);
     AdType              = new AdTypeRepository(_dbCtx);
     PropertyCategory    = new PropertyCategoryRepository(_dbCtx);
     PropertyCondition   = new PropertyConditionRepository(_dbCtx);
     PropertyImage       = new PropertyImageRepository(_dbCtx);
     PropertyPurpose     = new PropertyPurposeRepository(_dbCtx);
     PropertyRating      = new PropertyRatingRepository(_dbCtx);
     Property            = new PropertyRepository(_dbCtx);
     PropertyRequisition = new PropertyRequisitionRepository(_dbCtx);
     SubscriptionType    = new SubscriptionTypeRepository(_dbCtx);
     Subscription        = new SubscriptionRepository(_dbCtx);
     TagType             = new TagTypeRepository(_dbCtx);
     Tennant             = new TennantRepository(_dbCtx);
     Owner          = new OwnerRepository(_dbCtx);
     Tags           = new TagsRepository(_dbCtx);
     Message        = new MessageRepository(_dbCtx);
     User           = new UserRepository(_dbCtx);
     UserType       = new UserTypeRepository(_dbCtx);
     UserTypeAssoc  = new UserTypeAssocRepository(_dbCtx);
     MessageTrash   = new MessageTrashRepository(_dbCtx);
     Meeting        = new MeetingRepository(_dbCtx);
     MeetingMembers = new MeetingMembersRepository(_dbCtx);
 }
コード例 #3
0
        public void CanFailWithNullDescription()
        {
            TagTypeRepository repo = new TagTypeRepository();

            Assert.Throws(typeof(SQLiteException), () =>
                          repo.Add(new TagType())
                          );
        }
コード例 #4
0
        public void CanAddTagType()
        {
            TagTypeRepository repo = new TagTypeRepository();

            repo.Add(new TagType
            {
                Description = "tag type"
            });
        }
コード例 #5
0
        public void CanGetTagTypeNoReferences()
        {
            TagTypeRepository repo    = new TagTypeRepository();
            TagType           tagType = new TagType
            {
                Description = "tag type"
            };

            repo.Add(tagType);

            Assert.AreEqual(tagType, repo.GetById(tagType.Id));
        }
コード例 #6
0
        public void CanDeleteTagType()
        {
            TagTypeRepository repo    = new TagTypeRepository();
            TagType           tagType = new TagType
            {
                Description = "tag type"
            };

            repo.Add(tagType);

            repo.Delete(tagType.Id);

            Assert.Null(repo.GetById(tagType.Id));
        }
コード例 #7
0
        public void CanUpdateTagType()
        {
            TagTypeRepository repo    = new TagTypeRepository();
            TagType           tagType = new TagType
            {
                Description = "tag type"
            };

            repo.Add(tagType);

            const string newDescription = "newDescription";

            tagType.Description = newDescription;
            repo.Update(tagType);

            Assert.AreEqual(newDescription, repo.GetById(tagType.Id).Description);
        }
コード例 #8
0
        public void CanGetAllTagTypes()
        {
            TagTypeRepository repo     = new TagTypeRepository();
            TagType           tagType1 = new TagType {
                Description = "tt1"
            };
            TagType tagType2 = new TagType {
                Description = "tt2"
            };

            repo.Add(tagType1);
            repo.Add(tagType2);

            TagType[] tagTypes = repo.GetAll().ToArray();

            Assert.True(tagTypes.Contains(tagType1));
            Assert.True(tagTypes.Contains(tagType2));
        }
コード例 #9
0
        public RegisterTagResponse RegisterTag(RegisterTagRequest request)
        {
            var tag = TagRepository.RetrieveTag(request.BeaconId,
                                                request.BeaconMajorVersion,
                                                request.BeaconMinorVersion);

            if (tag == null || !tag.Active)
            {
                return(CreateFailedTagResponse("Tag not active"));
            }

            var user = UserRepository.RetrieveUser(request.SessionId);

            if (user == null)
            {
                return(CreateFailedTagResponse("Session not Valid"));
            }

            var tagType = TagTypeRepository.RetrieveTagType(tag.TagTypeId);

            if (tagType == null)
            {
                return(CreateFailedTagResponse("Invalid Tag Type"));
            }

            if (TagRepository.CheckTagIsNotWithinTimeout(user.UserId, tag.TagId, tagType.LockoutTimePeriod))
            {
                return(CreateFailedTagResponse("Tag seen within Timeout"));
            }

            var pointsScored = tagType.Points + tag.AdditionalPoints;

            var achievements = AchievementRepository.RetrieveAvailableAchievements(user.UserId, tag.TagId);

            var achievementNames = new List <string>();

            if (achievements != null)
            {
                foreach (var achievement in achievements)
                {
                    achievementNames.Add(achievement.AchievementName);
                    if (achievement.RewardPoints > 0)
                    {
                        TransactionRepository.CreateTransaction(user.UserId, achievement.RewardPoints, TransactionType.AchievementBonus);
                    }
                }
            }

            TransactionRepository.CreateTransactionForUserAndTag(user.UserId, pointsScored, tag.TagId, TransactionType.Tag);

            user = UserRepository.UpdateUser(user);

            var top = UserRepository.RetrieveTopLeaderboard(3, user.UserId);

            return(new RegisterTagResponse
            {
                PointsScored = pointsScored,
                NewPointsTotal = TransactionRepository.GetUsersPoints(user.UserId),
                UsablePoints = TransactionRepository.GetUsersUsablePoints(user.UserId),
                Achievements = achievementNames.ToArray(),
                Top10 = top.Select(LeaderboardResponseEntry.FromModel).ToArray(),
                Ranking = 0,
                LockoutTime = tagType.LockoutTimePeriod,
                Success = true,
                ErrorMessage = string.Empty
            });
        }