public Coach CreateCoach(HealthProfileInformation healthProfileInfo) { var coach = new Coach(healthProfileInfo); _coachRepository.SaveCoach(coach); _userTypeRepository.SaveUserType(coach.UserId, UserType.Coach); return(coach); }
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()); }
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; }
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); }
public Coach(HealthProfileInformation healthProfileInfo) : base(healthProfileInfo) { }
public Player(HealthProfileInformation healthProfileInfo, string coachId) : base(healthProfileInfo) { CoachId = coachId; }
public User(HealthProfileInformation healthProfileInfo) { Map(healthProfileInfo); }
public void SetProfileInfo(HealthProfileInformation profile) { SaveValue(ProfileInfo, profile); }