/// <summary>
 /// Deprecated Method for adding a new object to the GLB_Token EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToGLB_Token(GLB_Token gLB_Token)
 {
     base.AddObject("GLB_Token", gLB_Token);
 }
 /// <summary>
 /// Create a new GLB_Token object.
 /// </summary>
 /// <param name="id">Initial value of the Id property.</param>
 /// <param name="expirationDate">Initial value of the ExpirationDate property.</param>
 /// <param name="type">Initial value of the Type property.</param>
 /// <param name="name">Initial value of the Name property.</param>
 /// <param name="value">Initial value of the Value property.</param>
 public static GLB_Token CreateGLB_Token(global::System.Int32 id, global::System.DateTime expirationDate, global::System.String type, global::System.String name, global::System.String value)
 {
     GLB_Token gLB_Token = new GLB_Token();
     gLB_Token.Id = id;
     gLB_Token.ExpirationDate = expirationDate;
     gLB_Token.Type = type;
     gLB_Token.Name = name;
     gLB_Token.Value = value;
     return gLB_Token;
 }
        private MailMessage EmailMessageToUser(User user, DateTime utcNow, bool isTrial)
        {
            TokenId tokenId;

            // Setting verification token.
            using (var db2 = this.CreateNewCerebelloEntities())
            {
                var token = new GLB_Token();
                token.Value = Guid.NewGuid().ToString("N");
                token.Type = "VerifyPracticeAndEmail";
                token.Name = string.Format("Practice={0}&UserName={1}", user.Practice.UrlIdentifier, user.UserName);
                token.ExpirationDate = utcNow.AddHours(Constants.MAX_HOURS_TO_VERIFY_TRIAL_ACCOUNT);
                db2.GLB_Token.AddObject(token);
                db2.SaveChanges();

                tokenId = new TokenId(token.Id, token.Value);
            }

            // Rendering message bodies from partial view.
            var emailViewModel = new UserEmailViewModel(user) { Token = tokenId.ToString(), IsTrial = isTrial };
            var toAddress = new MailAddress(user.Person.Email, user.Person.FullName);
            var emailMessageToUser = this.CreateEmailMessage("ConfirmationEmail", toAddress, emailViewModel);

            return emailMessageToUser;
        }