Example #1
0
        public ActionResult TransactionDetails(int transactionId)
        {
            Transaction transaction = TransactionHandler.getTransaction(transactionId);

            Profile buyer  = ProfileHandler.GetProfile(transaction.BuyerId);
            Profile seller = ProfileHandler.GetProfile(transaction.SellerId);

            if (User.Identity.Name == buyer.Email)
            {
                transaction.CurrentUser      = ActionBy.Buyer;
                transaction.CounterPartyName = seller.Name;
            }
            else
            {
                transaction.CurrentUser      = ActionBy.Seller;
                transaction.CounterPartyName = buyer.Name;
            }

            if ((transaction.CurrentUser == ActionBy.Buyer && transaction.Confirmed == Confirmed.ByBuyer) ||
                (transaction.CurrentUser == ActionBy.Seller && transaction.Confirmed == Confirmed.BySeller))
            {
                transaction.ConfirmedByCurrentUser = true;
            }
            else
            {
                transaction.ConfirmedByCurrentUser = false;
            }

            TransactionCommentModel model = new TransactionCommentModel(transaction, User.Identity.Name);

            return(View(model));
        }
Example #2
0
        public async Task <IActionResult> GetProfileByUserId([FromQuery] Guid userId)
        {
            try
            {
                if (userId != null)
                {
                    var profile = await ProfileHandler.GetProfile(userId);

                    if (profile == null)
                    {
                        return(StatusCode(505, "Profile was not found"));
                    }
                    else
                    {
                        var measurements = await MeasurementsHandler.GetMeasurements(userId);

                        profile.profileMeasurements = measurements;
                    }
                    Logger.LogWarning("Profile Found");
                    return(Ok(profile));
                }
                return(StatusCode(505, "Missing User Id"));
            }
            catch (Exception ex)
            {
                Logger.LogError(ex.ToString());
                return(StatusCode(505, ex.Message));
            }
        }
        public ActionResult Index()
        {
            var viewModel      = new ProfileViewModel();
            var profileHandler = new ProfileHandler();

            viewModel.SetByProfile(profileHandler.GetProfile(new AspNetUserHandler()
                                                             .GetAspNetUser(User.Identity.GetUserName())
                                                             .Profile.Id));
            return(View(viewModel));
        }
Example #4
0
        public void TestGetProfile()
        {
            var mock        = new Mock <IProfileRepository>();
            var profileGuid = new Guid();
            var profile     = new Profile
            {
                FirstName = "testFristName",
                LastName  = "testLastName",
                Id        = profileGuid
            };

            mock.Setup(framework => framework.GetProfile(profileGuid))
            .Returns(profile);
            IProfileRepository profileRepository = mock.Object;
            var profileHandler = new ProfileHandler(profileRepository);

            Assert.AreEqual("testFristName", profileHandler.GetProfile(profileGuid).FirstName);
            Assert.AreEqual("testLastName", profileHandler.GetProfile(profileGuid).LastName);
            Assert.AreEqual(profile, profileHandler.GetProfile(profileGuid));
        }
Example #5
0
        public ActionResult TransactionHistory()
        {
            string  username = User.Identity.Name;
            Profile profile  = ProfileHandler.GetProfile(username);
            IEnumerable <Transaction> transactions = TransactionHandler.getUserTransactionHistory(profile.ProfileId);

            IEnumerable <TransactionDetailModel> detailedHistory = transactions.Select(
                x => new TransactionDetailModel(x));

            return(View(detailedHistory));
        }
Example #6
0
    /// <summary>
    /// Displays scores from previous matches
    /// </summary>
    /// <param name="stats">Score information</param>
    private void DisplayPreviousMatches_(List <IGrouping <DateTime, StatContent> > stats)
    {
        var ph = new ProfileHandler();

        ph.Initialise();

        // order by date
        var sorted = stats.OrderByDescending(s => s.Key).ToList();

        var index = 0;

        // loop though controls - up to 5
        for (; index < PreviousResults.Count() && index < sorted.Count(); index++)
        {
            // find active player
            var activePlayerId = _playerDisplaysInUse[_playerIndex].PlayerID();
            var player         = sorted[index].Where(s => s.GetPlayerId() == activePlayerId).FirstOrDefault();

            // get other players who played
            var otherPlayers = sorted[index].Where(s => s.GetPlayerId() != activePlayerId);

            // work out the scores
            var plScore  = player?.GetScore();
            var maxScore = sorted[index].Max(s => s.GetScore());

            var otherCharacters = new List <int>();

            // get a list of the characters that were used by other players
            foreach (var p in otherPlayers)
            {
                var profile = ph.GetProfile(p.GetPlayerId());
                if (profile != null)
                {
                    otherCharacters.Add(profile.GetCharacterIndex());
                }
            }

            // initialise controls
            PreviousResults[index].gameObject.SetActive(true);
            PreviousResults[index].SetData(sorted[index].Key, (int)plScore, otherCharacters, plScore == maxScore);
        }

        // hind unused controls
        for (; index < PreviousResults.Count(); index++)
        {
            PreviousResults[index].gameObject.SetActive(false);
        }
    }
Example #7
0
        public TransactionCommentModel(Transaction transaction, string userName)
        {
            Details         = new TransactionDetailModel(transaction);
            profile         = ProfileHandler.GetProfile(userName);
            UserId          = profile.ProfileId;
            UserDisplayName = profile.Name;
            UserFacebookId  = profile.FacebookId;

            if (UserId == transaction.BuyerId)
            {
                CounterPartyId = transaction.SellerId;
                UserAction     = ActionBy.Buyer;
            }
            else
            {
                CounterPartyId = transaction.BuyerId;
                UserAction     = ActionBy.Seller;
            }

            Profile counterPartyProfile = ProfileHandler.GetProfile(CounterPartyId);

            CounterPartyDisplayName = counterPartyProfile.Name;
            CounterPartyFacebookId  = counterPartyProfile.FacebookId;

            // load comments
            Comments = CommentHandler.getComments(transaction.TransactionId);
            foreach (Comment comment in Comments)
            {
                if (comment.UserId == UserId)
                {
                    comment.CommentByCurrentUser = true;
                }
                else
                {
                    comment.CommentByCurrentUser = false;
                }
            }
        }
Example #8
0
 public Comment(
     int commentId,
     string comment,
     int userId,
     ActionBy actionBy,
     int transactionId,
     int isActive,
     int isDeleted,
     DateTime createdDate,
     DateTime modifiedDate
     )
 {
     CommentId          = commentId;
     UserId             = userId;
     ActionBy           = actionBy;
     TransactionId      = transactionId;
     this.comment       = comment;
     IsActive           = isActive;
     IsDeleted          = isDeleted;
     CreatedDate        = createdDate;
     ModifiedDate       = modifiedDate;
     CommentatorProfile = ProfileHandler.GetProfile(UserId);
 }
Example #9
0
    /// <summary>
    /// Displays high score data
    /// </summary>
    /// <param name="stats">The data to show</param>
    private void ShowHighscores_(List <StatContent> stats)
    {
        var ph = new ProfileHandler();

        ph.Initialise();

        var index = 0;

        for (; (index < stats.Count && index < HighScores.Length); index++)
        {
            HighScores[index].gameObject.SetActive(true);
            var profile = ph.GetProfile(stats[index].GetPlayerId());
            if (profile != null)
            {
                HighScores[index].SetPlayerData(profile.GetProfileName(), stats[index].GetScore(), profile.GetCharacterIndex());
            }
        }

        for (; index < HighScores.Length; index++)
        {
            HighScores[index].gameObject.SetActive(false);
        }
    }