yavsc/yavscModel/RolesAndMembers/Profile.cs
Paul Schneider 3355f9fed0 * bg.gif:
* asc.gif:
* desc.gif:
* style.css: moved to App_Themes

* style.css:
* bg.gif:
* asc.gif:
* bg.png:
* rect.png:
* asc.png:
* desc.gif:
* jquery-ui.css:
* mdd_styles.css:
* croix.png:
* desc.png:
* style.css:
* jquery-ui.min.css:
* mdd_gripper.png:
* mdd_toolbar.png:
* jquery.timepicker.css:
* mdd_ajax_loader.gif:
* mdd_modal_background.png: moved to /App_Themes

* NpgsqlBlogProvider.cs: * Remove post by id
* Manage collections of entries on a couple (user,title), not a single
  post

* NpgsqlCircleProvider.cs: Fixes the "Match" method.

* IDbModule.cs:
* Edit.aspx:
* Estimates.aspx:
* WorkFlowManager.cs:
* NpgsqlContentProvider.cs: refactoring

* NpgsqlMRPProviders.csproj: new NpgsqlUserName provider

* NpgsqlRoleProvider.cs: simpler init method

* NpgsqlUserNameProvider.cs: impements a UserNameProvider

* MyClass.cs: refactoring from Yavsc.Model

* BlogsController.cs: access control simplified

* FrontOfficeController.cs: Pdf generation made public ni case of
  formatting exception

* mdd_styles.css: Theme -> App_Themes

* style.css: yet another style impact

* AccountController.cs: Fixes the user name modification

* BlogsController.cs: * Fixes the removal process
* On a title and user name, we get collection of posts, not only one.
* Implements an Access on circle

* FrontOfficeController.cs: * implements a new Get method.
* ensure a membership existence before delivering an estimate.

* GoogleController.cs: Fixes the user name modification on a Google
  account

* ErrorHtmlFormatter.cs: nice error message in html (using Markdown
  helper)

* FormatterException.cs: formatter exception exposes error and
  standard output of the process

* TexToPdfFormatter.cs: * generates temporary files in the folder
  returned by Path.GetTempPath()
* throws FormatterException

* Global.asax.cs: new route map:
Blogs/{action}/{user}/{title}
Blog/{user}/{title}
B/{id}
{controller}/{action}/{id}

* App.master: * refactoring: Theme moved to App_Themes
* a link to the logged user's blog
*

* NoLogin.master: refactoring: Theme moved to App_Themes

* Circles.aspx: refactoring : circles now are given as select items

* Login.aspx: fixes the html presentation

* Register.aspx: Fixes a Typo

* Index.aspx: Implements a blog index, due to M&C changes with this
  commit

* RemovePost.aspx: links to the new route to the "RemovePost" action,
  giving it a post id

* RemoveTitle.aspx: fixes a not yet linked page to remove a post
  collection under a given title

* EventPub.aspx: code refactoring

* Writting.ascx: cleans the code

* Web.config: fills the config with new names in the space

* Web.config: configures the new NpgsqlUserNameProvider

* Web.csproj: refactoring and others

* BlogEntryCollection.cs: implement the BlogEntryCollection

* BlogManager.cs: the manager helps to filter on access

* BlogProvider.cs: The title is not unique anymore, and one can modify
  it, post a lot under it, drop all posts under it.
A Post is deleted by id.

* UUBlogEntryCollection.cs: implements a collection of post under a
  given user name.

* UUTBlogEntryCollection.cs: implements a collection of post under a
  given couple (user name, title).

* ListItem.cs: ListItem is declared obsolete in this model, helpers
  can build MVC SelectListItem on data returned by the manager.

* LocalizedText.Designer.cs:
* LocalizedText.fr.Designer.cs: autogenerated from xml

* LocalizedText.resx:
* LocalizedText.fr.resx: new labels

* ChangeUserNameProvider.cs: xml doc

* Profile.cs: the UserName property is read only, and comes from
  authentication, to change it, we set a Name and validate it agains
  the "Profile" method

* UserManager.cs: simpler code a init time

* IContentProvider.cs: implements the new IDataProvider interface

* IDataProvider.cs: defines the new IDataProvider interface

* YavscModel.csproj: includes new classes

* UserPosts.aspx: adds a link to remove a post

* UserPost.aspx: now uses the new BlogEntryCollection object
2015-08-04 02:10:28 +02:00

298 lines
8.2 KiB
C#

using System;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
using System.Web.Profile;
using System.Web.Security;
using System.Web;
using System.Configuration;
namespace Yavsc.Model.RolesAndMembers
{
/// <summary>
/// Profile.
/// </summary>
public class Profile
{
/// <summary>
/// Gets or sets the name.
/// </summary>
/// <value>The name.</value>
[DisplayName ("Nom complet")]
[StringLength (1024)]
public string Name { get; set; }
/// <summary>
/// Gets or sets the avatar.
/// </summary>
/// <value>The avatar.</value>
[DisplayName("Avatar")]
public string avatar { get; set; }
/// <summary>
/// Gets or sets the address.
/// </summary>
/// <value>The address.</value>
[DisplayName ("Adresse")]
[StringLength (2047)]
public string Address { get; set; }
/// <summary>
/// Gets or sets the state of the city and.
/// </summary>
/// <value>The state of the city and.</value>
[DisplayName ("Ville")]
[StringLength (255)]
public string CityAndState { get; set; }
/// <summary>
/// Gets or sets the zip code.
/// </summary>
/// <value>The zip code.</value>
[DisplayName ("Code Postal")]
[StringLength (9)]
public string ZipCode { get; set; }
/// <summary>
/// Gets or sets the country.
/// </summary>
/// <value>The country.</value>
[DisplayName ("Pays")]
[StringLength (99)]
public string Country { get; set; }
/// <summary>
/// Gets or sets the web site.
/// </summary>
/// <value>The web site.</value>
[DisplayName ("Site Web")]
[StringLength (255)]
public string WebSite { get; set; }
/// <summary>
/// Gets or sets a value indicating whether this <see cref="Yavsc.Model.RolesAndMembers.Profile"/> blog visible.
/// </summary>
/// <value><c>true</c> if blog visible; otherwise, <c>false</c>.</value>
[DisplayName ("Blog visible")]
public bool BlogVisible { get; set; }
private string blogTitle;
/// <summary>
/// Gets or sets the blog title.
/// </summary>
/// <value>The blog title.</value>
[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; } }
/// <summary>
/// Gets or sets the phone number.
/// </summary>
/// <value>The phone.</value>
[DisplayName ("Téléphone fixe")]
[StringLength (15)]
public string Phone { get; set; }
/// <summary>
/// Gets or sets the mobile.
/// </summary>
/// <value>The mobile.</value>
[DisplayName ("Portable")]
[StringLength (15)]
public string Mobile { get; set; }
/// <summary>
/// Gets or sets the BI.
/// </summary>
/// <value>The BI.</value>
[DisplayName ("Code BIC")]
[StringLength (15)]
public string BIC { get; set; }
/// <summary>
/// Gets or sets the IBA.
/// </summary>
/// <value>The IBA.</value>
[DisplayName ("Code IBAN")]
[StringLength (33)]
public string IBAN { get; set; }
/// <summary>
/// Gets or sets the bank code.
/// </summary>
/// <value>The bank code.</value>
[DisplayName ("Code Banque")]
[StringLength (5)]
public string BankCode { get; set; }
/// <summary>
/// Gets or sets the wicket code.
/// </summary>
/// <value>The wicket code.</value>
[DisplayName ("Code Guichet")]
[StringLength (5)]
public string WicketCode { get; set; }
/// <summary>
/// Gets or sets the account number.
/// </summary>
/// <value>The account number.</value>
[DisplayName ("Numéro de compte")]
[StringLength (15)]
public string AccountNumber { get; set; }
/// <summary>
/// Gets or sets the banked key.
/// </summary>
/// <value>The banked key.</value>
[DisplayName ("Clé RIB")]
public int BankedKey { get; set; }
/// <summary>
/// Gets or sets the google calendar.
/// </summary>
/// <value>The google calendar.</value>
[Display(Name="Google_calendar",ResourceType=typeof(LocalizedText))]
public string GoogleCalendar { get; set; }
/// <summary>
/// Gets a value indicating whether this instance has bank account.
/// </summary>
/// <value><c>true</c> if this instance has bank account; otherwise, <c>false</c>.</value>
public bool HasBankAccount {
get {
return !(
(
string.IsNullOrWhiteSpace (BankCode)
|| string.IsNullOrWhiteSpace (WicketCode)
|| string.IsNullOrWhiteSpace (AccountNumber)
|| BankedKey == 0
)
&&
( string.IsNullOrWhiteSpace (BIC)
|| string.IsNullOrWhiteSpace (IBAN))
); } }
/// <summary>
/// Gets a value indicating whether this instance has postal address.
/// </summary>
/// <value><c>true</c> if this instance has postal address; otherwise, <c>false</c>.</value>
public bool HasPostalAddress {
get {
return !string.IsNullOrWhiteSpace (Address)
&& !string.IsNullOrWhiteSpace (CityAndState)
&& !string.IsNullOrWhiteSpace (ZipCode);
}
}
/// <summary>
/// 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
///
/// </summary>
/// <value><c>true</c> if this instance is billable; otherwise, <c>false</c>.</value>
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;
/// <summary>
/// Gets or sets the name of the user.
/// </summary>
/// <value>The name of the user.</value>
public string UserName { get { return userName; } }
public Profile () : base ()
{
}
/// <summary>
/// Gets or sets a value indicating whether this <see cref="Yavsc.Model.RolesAndMembers.Profile"/> remember me.
/// </summary>
/// <value><c>true</c> if remember me; otherwise, <c>false</c>.</value>
public bool RememberMe { get; set; }
/// <summary>
/// Initializes a new instance of the <see cref="Yavsc.Model.RolesAndMembers.Profile"/> class.
/// </summary>
/// <param name="profile">Profile.</param>
public Profile (ProfileBase profile)
{
object b = profile.GetPropertyValue ("BlogVisible");
BlogVisible = (b == null) ? true : (b is DBNull)? true : (bool)b;
object s = profile.GetPropertyValue ("BlogTitle");
BlogTitle = (s is DBNull) ? null : (string)s;
s = profile.GetPropertyValue ("avatar");
avatar = (s is DBNull) ? null : (string)s;
s = profile.GetPropertyValue ("Address");
Address = (s is DBNull) ? null : (string)s;
s = profile.GetPropertyValue ("CityAndState");
CityAndState = (s is DBNull) ? null : (string)s;
s = profile.GetPropertyValue ("Country");
Country = (s is DBNull) ? null : (string)s;
s = profile.GetPropertyValue ("ZipCode");
ZipCode = (s is DBNull) ? null : (string)s;
s = profile.GetPropertyValue ("WebSite");
WebSite = (s is DBNull) ? null : (string)s;
s = profile.GetPropertyValue ("Name");
Name = (s is DBNull) ? null : (string)s;
s = profile.GetPropertyValue ("Phone");
Phone = (s is DBNull) ? null : (string)s;
s = profile.GetPropertyValue ("Mobile");
Mobile = (s is DBNull) ? null : (string)s;
userName = profile.UserName;
s = profile.GetPropertyValue ("BankCode");
BankCode = (s is DBNull) ? null : (string)s;
s = profile.GetPropertyValue ("IBAN");
IBAN = (s is DBNull) ? null : (string)s;
s = profile.GetPropertyValue ("BIC");
BIC = (s is DBNull) ? null : (string)s;
s = profile.GetPropertyValue ("WicketCode");
WicketCode = (s is DBNull) ? null : (string)s;
s = profile.GetPropertyValue ("AccountNumber");
this.AccountNumber = (s is DBNull) ? null : (string)s;
s = profile.GetPropertyValue ("BankedKey");
BankedKey = (s == null) ? 0 : (s is DBNull)? 0 : (int)s;
s = profile.GetPropertyValue ("gcalid");
GoogleCalendar = (s is DBNull)? null : (string) s;
}
}
}