// // PerformerProfile.cs // // Author: // Paul Schneider // // Copyright (c) 2015 GNU GPL // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Lesser General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU Lesser General Public License for more details. // // You should have received a copy of the GNU Lesser General Public License // along with this program. If not, see . using System; using Yavsc.Model.RolesAndMembers; using Yavsc.Model.Skill; using System.Web.Security; using System.Web.Profile; using System.Collections.Generic; using Yavsc.Model; using System.ComponentModel; using System.ComponentModel.DataAnnotations; using System.Linq; using Yavsc.Model.Google.Api; namespace Yavsc.Model.FrontOffice { /// /// Performer profile. /// public class PerformerProfile: UserNameBase, IRating, IIdentified { /// /// Initializes a new instance of the class. /// public PerformerProfile() { } /// /// Gets or sets the identifier. /// /// The identifier. public long Id { get; set; } public int Rate { get; set; } /// /// Gets or sets the skills. /// /// The skills. public virtual IEnumerable Skills { get; set; } /// /// Initializes a new instance of the class. /// /// Username. public PerformerProfile(string username) { UserName = username; } /// /// Gets the user. /// /// The user. public MembershipUser GetUser() { return Membership.GetUser (UserName); } private Profile yavscCLientProfile = null; /// /// Gets the yavsc Client profile. /// /// The yavsc Client profile. public Profile YavscClientProfile { get { if (yavscCLientProfile == null) if (UserName == null) throw new Exception ("UserName not set"); else yavscCLientProfile = new Profile ( ProfileBase.Create (UserName)); return yavscCLientProfile; } } public string EMail { get ; set; } public string GoogleRegId { get { return YavscClientProfile.GoogleRegId; } } public string GoogleCalId { get { return YavscClientProfile.GoogleCalendar; } } /// /// Determines whether this instance references the specified skillId. /// /// true if this instance has skill the specified skillId; otherwise, false. /// Skill identifier. public bool HasSkill(long skillId) { return Skills.Any (x => x.SkillId == skillId); } /// /// Gets the avatar. /// /// The avatar. public string Avatar { get { return YavscClientProfile.avatar; } } /// /// Determines whether this instance has calendar. /// /// true if this instance has calendar; otherwise, false. public bool HasCalendar () { return (YavscClientProfile.GoogleCalendar != null); } /// /// Creates the availability description object. /// /// The availability. /// Date. /// If set to true available. public PerformerAvailability CreateAvailability(DateTime date, bool available) { PerformerAvailability p = new PerformerAvailability(this,UserName,date,available); p.DateAvailable = available; p.PerformanceDate = date; return p; } } }