using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Samples.ServiceHosting.StorageClient;
using newtelligence.DasBlog.Web;
namespace newtelligence.DasBlog.Runtime.Azure{
public class UserEntity : TableStorageEntity
{
/// <summary>
///
/// </summary>
/// <remarks>Empty constructor required for Azure Data Services.</remarks>
public UserEntity()
: base()
{
//...
}
public UserEntity(User user)
: base()
{
this.Active = user.Active;
this.Ask = user.Ask;
this.DisplayName = user.DisplayName;
this.EmailAddress = user.EmailAddress;
this.Name = user.Name;
this.NotifyOnAllComment = user.NotifyOnAllComment;
this.NotifyOnNewPost = user.NotifyOnNewPost;
this.NotifyOnOwnComment = user.NotifyOnOwnComment;
this.OpenIDUrl = user.OpenIDUrl;
this.Role = user.Role;
// let the User class handle the encryption of the password.
this.Password = user.XmlPassword;
// change this?
this.PartitionKey = user.Name;
this.RowKey = Guid.NewGuid().ToString();
}
public bool Active { get; set; }
public bool Ask { get; set; }
public string DisplayName { get; set; }
private string email;
public string EmailAddress
{
get { return this.email; }
set
{
this.email = value == null ? null : value.ToLowerInvariant();
}
}
private string name;
public string Name
{
get
{
return this.name;
}
set
{
this.name = value;
this.NameLower = value == null ? null : value.ToLowerInvariant();
}
}
public string NameLower{get;set;}
public bool NotifyOnAllComment { get; set; }
public bool NotifyOnNewPost { get; set; }
public bool NotifyOnOwnComment { get; set; }
public string OpenIDUrl { get; set; }
public string Password { get; set; }
public string Role { get; set; }
public User GetUser()
{
return new User()
{
Active = this.Active,
Ask = this.Ask,
DisplayName = this.DisplayName,
EmailAddress = this.EmailAddress,
Name = this.Name,
NotifyOnAllComment = this.NotifyOnAllComment,
NotifyOnNewPost = this.NotifyOnNewPost,
NotifyOnOwnComment = this.NotifyOnOwnComment,
OpenIDUrl = this.OpenIDUrl,
Role = this.Role,
// let the User class handle the encryption of the password.
XmlPassword = this.Password,
};
}
}
}
|