예제 #1
0
        public Coach CreateCoach(HealthProfileInformation healthProfileInfo)
        {
            var coach = new Coach(healthProfileInfo);

            _coachRepository.SaveCoach(coach);
            _userTypeRepository.SaveUserType(coach.UserId, UserType.Coach);

            return(coach);
        }
예제 #2
0
        public static string GenerateUserId(HealthProfileInformation healthProfileInfo)
        {
            var userInfoString = healthProfileInfo.FirstName +
                                 healthProfileInfo.Birthdate +
                                 healthProfileInfo.CreatedTime +
                                 healthProfileInfo.Gender;

            MD5 md5Hasher  = MD5.Create();
            var hashedInfo = md5Hasher.ComputeHash(Encoding.UTF8.GetBytes(userInfoString));
            var intValue   = BitConverter.ToInt32(hashedInfo, 0);

            return(intValue.ToString());
        }
예제 #3
0
        public void Map(HealthProfileInformation healthProfileInfo)
        {
            UserId = GenerateUserId(healthProfileInfo);

            FirstName       = healthProfileInfo.FirstName;
            LastName        = healthProfileInfo.LastName;
            Gender          = healthProfileInfo.Gender;
            Height          = healthProfileInfo.Height;
            Weight          = healthProfileInfo.Weight;
            PostalCode      = healthProfileInfo.PostalCode;
            PreferredLocale = healthProfileInfo.PreferredLocale;
            Birthdate       = healthProfileInfo.Birthdate;
            CreatedTime     = healthProfileInfo.CreatedTime;
            LastUpdateTime  = healthProfileInfo.LastUpdateTime;
        }
예제 #4
0
        public Player CreatePlayer(string initialId, HealthProfileInformation profile, string coachId)
        {
            // Here we assume user is unassigned user
            var player = _playerRepository.GetPlayer(initialId);

            if (player.CoachId != coachId)
            {
                throw new InvalidOperationException("Player has been assigned to a differnt coach");
            }

            var newId = User.GenerateUserId(profile);

            if (_playerRepository.GetPlayer(newId) != null)
            {
                throw new ExistingUserException("This player has already been created");
            }

            player.Map(profile);

            UpdateUnassignedToPlayer(initialId, player);

            return(player);
        }
예제 #5
0
 public Coach(HealthProfileInformation healthProfileInfo) : base(healthProfileInfo)
 {
 }
예제 #6
0
파일: Player.cs 프로젝트: msulamy/ehealth18
 public Player(HealthProfileInformation healthProfileInfo, string coachId) : base(healthProfileInfo)
 {
     CoachId = coachId;
 }
예제 #7
0
 public User(HealthProfileInformation healthProfileInfo)
 {
     Map(healthProfileInfo);
 }
예제 #8
0
 public void SetProfileInfo(HealthProfileInformation profile)
 {
     SaveValue(ProfileInfo, profile);
 }