using System; using System.ComponentModel; using System.ComponentModel.DataAnnotations; using System.Web.Profile; using System.Web.Security; using System.Web; using System.Configuration; using System.Collections.Generic; using System.Web.Mvc; using Yavsc.Model.WorkFlow; namespace Yavsc.Model.RolesAndMembers { /// /// Profile. /// public class Profile { /// /// Gets or sets the name. /// /// The name. [DisplayName ("Nom complet")] [StringLength (1024)] public string Name { get; set; } /// /// Gets or sets the avatar. /// /// The avatar. [DisplayName("Avatar")] public string avatar { get; set; } /// /// Gets or sets the address. /// /// The address. [DisplayName ("Adresse")] [StringLength (2047)] public string Address { get; set; } /// /// Gets or sets the user interface theme. /// /// The user interface theme. [DisplayName ("Thème")] [StringLength (2047)] public string UITheme { get; set; } /// /// Gets or sets the state of the city and. /// /// The state of the city and. [DisplayName ("Ville")] [StringLength (255)] public string CityAndState { get; set; } /// /// Gets or sets the zip code. /// /// The zip code. [DisplayName ("Code Postal")] [StringLength (9)] public string ZipCode { get; set; } /// /// Gets or sets the country. /// /// The country. [DisplayName ("Pays")] [StringLength (99)] public string Country { get; set; } /// /// Gets or sets the web site. /// /// The web site. [DisplayName ("Site Web")] [StringLength (255)] public string WebSite { get; set; } /// /// Gets or sets a value indicating whether this blog visible. /// /// true if blog visible; otherwise, false. [DisplayName ("Blog visible")] public bool BlogVisible { get; set; } private string blogTitle; /// /// Gets or sets the blog title. /// /// The blog title. [DisplayName ("Titre du blog")] [StringLength (255)] public string BlogTitle { get { return string.IsNullOrWhiteSpace(blogTitle)? (string.IsNullOrWhiteSpace(Name)? UserName:Name)+"'s blog":blogTitle; } set { blogTitle = value; } } /// /// Gets or sets the phone number. /// /// The phone. [DisplayName ("Téléphone fixe")] [StringLength (15)] public string Phone { get; set; } /// /// Gets or sets the mobile. /// /// The mobile. [DisplayName ("Portable")] [StringLength (15)] public string Mobile { get; set; } /// /// Gets or sets the BI. /// /// The BI. [DisplayName ("Code BIC")] [StringLength (15)] public string BIC { get; set; } /// /// Gets or sets the IBA. /// /// The IBA. [DisplayName ("Code IBAN")] [StringLength (33)] public string IBAN { get; set; } /// /// Gets or sets the bank code. /// /// The bank code. [DisplayName ("Code Banque")] [StringLength (5)] public string BankCode { get; set; } /// /// Gets or sets the wicket code. /// /// The wicket code. [DisplayName ("Code Guichet")] [StringLength (5)] public string WicketCode { get; set; } /// /// Gets or sets the account number. /// /// The account number. [DisplayName ("Numéro de compte")] [StringLength (15)] public string AccountNumber { get; set; } /// /// Gets or sets the banked key. /// /// The banked key. [DisplayName ("Clé RIB")] public int BankedKey { get; set; } /// /// Gets or sets the google calendar. /// /// The google calendar. [Display(Name="Google_calendar",ResourceType=typeof(LocalizedText))] public string GoogleCalendar { get; set; } [Display(Name="Google_registration_id",ResourceType=typeof(LocalizedText))] public string GoogleRegId { get; set; } /// /// Gets a value indicating whether this instance has bank account. /// /// true if this instance has bank account; otherwise, false. public bool HasBankAccount { get { return !( ( string.IsNullOrWhiteSpace (BankCode) || string.IsNullOrWhiteSpace (WicketCode) || string.IsNullOrWhiteSpace (AccountNumber) || BankedKey == 0 ) && ( string.IsNullOrWhiteSpace (BIC) || string.IsNullOrWhiteSpace (IBAN)) ); } } /// /// Gets a value indicating whether this instance has postal address. /// /// true if this instance has postal address; otherwise, false. public bool HasPostalAddress { get { return !string.IsNullOrWhiteSpace (Address) && !string.IsNullOrWhiteSpace (CityAndState) && !string.IsNullOrWhiteSpace (ZipCode); } } /// /// Gets a value indicating whether this instance is billable. /// Returns true when /// Name is not null and all of /// Address, CityAndState and ZipCode are not null, /// or one of Email or Phone or Mobile is not null /// /// /// true if this instance is billable; otherwise, false. public bool IsBillable { get { // true if has a name and, either a postal address, an email, or a Mobile phone number // Name is not null and // ( // (Address and CityAndState and ZipCode) // or Email or Phone or Mobile // ) return !string.IsNullOrWhiteSpace (Name) && !( (string.IsNullOrWhiteSpace (Address) || string.IsNullOrWhiteSpace (CityAndState) || string.IsNullOrWhiteSpace (ZipCode)) && string.IsNullOrWhiteSpace (Phone) && string.IsNullOrWhiteSpace (Mobile)); } } private string userName; /// /// Gets or sets the name of the user. /// /// The name of the user. [Localizable(true), Required(ErrorMessage = "S'il vous plait, entrez un nom d'utilisateur valide") ,Display(ResourceType=typeof(LocalizedText),Name="User_name"), RegularExpression("([a-z]|[A-Z]|[\\s-_.~]|[0-9])+") ] public string UserName { get { return userName; } set { userName=value; } } public Profile () : base () { } /// /// Gets or sets a value indicating whether this remember me. /// /// true if remember me; otherwise, false. public bool RememberMe { get; set; } /// /// Initializes a new instance of the class. /// /// Profile. public Profile (ProfileBase profile) { if (profile == null) throw new Exception ("No profile"); if (profile.UserName == null) throw new Exception ("UserName not set"); UITheme = (string) profile.GetPropertyValue ("UITheme"); userName = profile.UserName; if (profile.IsAnonymous) return; BlogVisible = (bool) profile.GetPropertyValue ("BlogVisible"); BlogTitle = (string) profile.GetPropertyValue ("BlogTitle"); avatar = (string) profile.GetPropertyValue ("Avatar"); Address = (string) profile.GetPropertyValue ("Address"); CityAndState = (string) profile.GetPropertyValue ("CityAndState"); Country = (string) profile.GetPropertyValue ("Country"); ZipCode = (string) profile.GetPropertyValue ("ZipCode"); WebSite = (string) profile.GetPropertyValue ("WebSite"); Name = (string) profile.GetPropertyValue ("Name"); Phone = (string) profile.GetPropertyValue ("Phone"); Mobile = (string) profile.GetPropertyValue ("Mobile"); BankCode = (string)profile.GetPropertyValue ("BankCode"); IBAN = (string)profile.GetPropertyValue ("IBAN"); BIC = (string)profile.GetPropertyValue ("BIC"); WicketCode = (string) profile.GetPropertyValue ("WicketCode"); AccountNumber = (string) profile.GetPropertyValue ("AccountNumber"); BankedKey = (int) profile.GetPropertyValue ("BankedKey"); GoogleCalendar = (string) profile.GetPropertyValue ("gcalid"); GoogleRegId = (string) profile.GetPropertyValue ("gregid"); MEACode = (string) profile.GetPropertyValue ("MEACode"); } /// /// Gets or sets the MEA code. /// /// The MEA code. [Display(ResourceType=typeof(LocalizedText),Name="MEACode"), RegularExpression(@"[a-zA-Z0-9 \-_.~/\\]*")] public string MEACode { get; set; } } }