/// <summary>
 /// Deprecated Method for adding a new object to the UserDetails EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToUserDetails(UserDetail userDetail)
 {
     base.AddObject("UserDetails", userDetail);
 }
        /// <summary>
        /// Finalises user signup
        /// Level: Logic
        /// </summary>
        /// <param name="Name">The Name</param>
        /// <param name="Surname">The Surname</param>
        /// <param name="DateOfBirth">The Date of Birth</param>
        /// <param name="Address">The Address</param>
        /// <param name="Email">The Email</param>
        /// <param name="Town">The Town</param>
        /// <param name="Postcode">The Postcode</param>
        /// <param name="Country">The Country</param>
        /// <param name="Username">The Username</param>
        /// <param name="Password">The Password</param>
        /// <returns>UserSignupEnum</returns>
        public UserSignup FinalizeSignUp(string Name, string Surname, DateTime DateOfBirth, string Address, string Email, string Town,
            string Postcode, string Country, string Username, string Password)
        {
            try
            {
                UsersRepository myRepository = new UsersRepository(false);

                try
                {
                    //Checking if Username Exists
                    if ((myRepository.UsernameExists(Username)) && (myRepository.EmailExists(Email)))
                    {
                        return UserSignup.UsernameAndEmailExist;
                    }
                    else if (myRepository.UsernameExists(Username))
                    {
                        return UserSignup.UsernameExists;
                    }
                    else if (myRepository.EmailExists(Email))
                    {
                        return UserSignup.EmailExists;
                    }
                    else
                    {
                        //Instanciating User
                        User myUser = new User();

                        myUser.Id = Guid.NewGuid();
                        myUser.Name = Name;
                        myUser.Surname = Surname;
                        myUser.DateOfBirth = DateOfBirth;
                        myUser.StreetAddress = Address;
                        myUser.Postcode = Postcode;
                        myUser.Email = Email;

                        //Retrieving UserType
                        myUser.UserType = myRepository.RetrieveUserTypeByName("Retailer");

                        //Retrieving Possible Same Town
                        Town myTown = myRepository.RetrieveTown(Town, Country);

                        //If Town Exists
                        if (myTown != null)
                        {
                            //Assigning Existent Town to User
                            myUser.Town = myTown;
                        }
                        else
                        {
                            //Instanciating New Town
                            myTown = new Town();
                            myTown.Town1 = Town;
                            myTown.Country = myRepository.RetrieveCountry(Country);

                            //Assigning New Town to User
                            myUser.Town = myTown;
                        }

                        //Instanciating User Details
                        UserDetail myUserDetails = new UserDetail();

                        myUserDetails.Id = Guid.NewGuid();
                        myUserDetails.Username = Username;
                        myUserDetails.Password = Password;

                        //Assigning User Details to User
                        myUser.UserDetail = myUserDetails;

                        //Assigning User Role to User
                        myUser.Roles.Add(myRepository.RetrieveRoleByName("User"));

                        //Saving Changes
                        myRepository.FinalizeSignUp(myUser);

                        //Returning Successful
                        return UserSignup.Successful;
                    }
                }
                catch (Exception Exception)
                {
                    //Throwing Exception
                    throw Exception;
                }
            }
            catch (Exception Exception)
            {
                throw Exception;
            }
        }
 /// <summary>
 /// Create a new UserDetail object.
 /// </summary>
 /// <param name="id">Initial value of the Id property.</param>
 /// <param name="username">Initial value of the Username property.</param>
 /// <param name="password">Initial value of the Password property.</param>
 public static UserDetail CreateUserDetail(global::System.Guid id, global::System.String username, global::System.String password)
 {
     UserDetail userDetail = new UserDetail();
     userDetail.Id = id;
     userDetail.Username = username;
     userDetail.Password = password;
     return userDetail;
 }