Ejemplo n.º 1
0
        public PasswordGameRequirement Convert(PasswordGameRequirementResource passwordResource)
        {
            var existingPasswordGameRequirement = CreatedPasswordGameRequirements.Where(obj => obj.Id == passwordResource.Id).FirstOrDefault();

            if (existingPasswordGameRequirement != null)
            {
                Assign(existingPasswordGameRequirement, passwordResource);
                return(existingPasswordGameRequirement);
            }
            else
            {
                var newPasswordGameRequirement = new PasswordGameRequirement();
                CreatedPasswordGameRequirements.Add(newPasswordGameRequirement);
                Assign(newPasswordGameRequirement, passwordResource);
                return(newPasswordGameRequirement);
            }
        }
Ejemplo n.º 2
0
        void Assign(PasswordGameRequirement password, PasswordGameRequirementResource passwordResource)
        {
            password.Id = passwordResource.Id;

            if (passwordResource.Question != null)
            {
                password.Question = passwordResource.Question;
            }

            if ((passwordResource.Passwords != null) && password.Passwords == null)
            {
                password.Passwords = new List <GamePassword>();

                foreach (GamePasswordResource gamePassword in passwordResource.Passwords)
                {
                    GamePassword newPasswords = Convert(gamePassword);
                    password.Passwords.Add(newPasswords);
                    newPasswords.PasswordGameRequirement = password;
                }
            }
        }