Ejemplo n.º 1
0
        private ScoreCard CreateScoreCard()
        {
            var cachedScoreCard = _sessionStorage.Get(_sessionKey);
            var scoreCard       = _mapper.Map <ScoreCard>(cachedScoreCard);

            _unitOfWork.ScoreCards.Add(scoreCard);
            _unitOfWork.Complete();

            return(scoreCard);
        }
Ejemplo n.º 2
0
        public async Task RemoveFriendAsync(string friendID)
        {
            var inloggedUsername = _accountService.GetUserName();
            var friend           = _unitOfWork.Friends.FindSingleBy(x => x.FriendID == Guid.Parse(friendID));

            if (friend.FriendRequestAccepted == true)
            {
                await RemoveExtraFriendAsync(friend.FriendUserID);
            }

            _unitOfWork.Friends.Delete(friend);
            _unitOfWork.Complete();
        }
Ejemplo n.º 3
0
        public async Task ChangeUserNameAsync(string newUserName)
        {
            var user = await _userManager.FindByNameAsync(_httpContextAccessor.HttpContext.User.Identity.Name);

            var oldUsername = _httpContextAccessor.HttpContext.User.Identity.Name;

            user.UserName           = newUserName;
            user.NormalizedUserName = newUserName;
            var result = await _userManager.UpdateAsync(user);

            if (result.Succeeded)
            {
                await _signInManager.RefreshSignInAsync(user);

                var scoreCards  = _unitOfWork.ScoreCards.GetAllScoreCardAndIncludePlayerCardAndHoleCardBy(x => x.UserID == user.Id);
                var friendItems = _unitOfWork.Friends.FindAllBy(x => x.UserName == oldUsername);


                foreach (var item in friendItems)
                {
                    item.UserName = newUserName;
                }
                _unitOfWork.Friends.EditRange(friendItems);

                foreach (var scoreCard in scoreCards)
                {
                    scoreCard.UserName = newUserName;
                    scoreCard.PlayerCards.FirstOrDefault(x => x.UserID == user.Id).UserName = newUserName;
                }
                _unitOfWork.ScoreCards.EditRange(scoreCards.ToList());
                _unitOfWork.Complete();
            }
        }
Ejemplo n.º 4
0
        public void SaveUpdatedCourse(CourseFormDto model)
        {
            var course = _mapper.Map(model, _unitOfWork.Courses.FindById(model.CourseID));

            course.Holes = _mapper.Map(model.Holes, _unitOfWork.Holes.FindAllBy(x => x.CourseID == model.CourseID));
            _unitOfWork.Courses.Edit(course);
            _unitOfWork.Complete();
        }
 public void SaveLocationsToDataBase(List <Course> courses)
 {
     _unitOfwork.Courses.AddRange(courses);
     _unitOfwork.Complete();
 }