00001 using System;
00002 using System.Collections.Generic;
00003 using System.Text;
00004 using Shared;
00005
00006 namespace Server
00007 {
00012 public class Project : UniquelyIdentifiable
00013 {
00014 private DateTime startDate;
00015 private DateTime endDate;
00016 private string subject;
00017 private string title;
00018 private string department;
00019 private string synopsis;
00020 private List<Role> roles;
00021 private List<Reference> references;
00022 private bool submitted;
00023
00036 public Project(int id, DateTime start, DateTime endDate, string subject, string title, string department, string synopsis, bool submitted)
00037 : base(id)
00038 {
00039 this.startDate = start;
00040 this.subject = subject;
00041 this.title = title;
00042 this.department = department;
00043 this.endDate = endDate;
00044 this.synopsis = synopsis;
00045 this.submitted = submitted;
00046 roles = new List<Role>();
00047 references = new List<Reference>();
00048 }
00049
00053 public bool IsSubmitted
00054 {
00055 get { return submitted; }
00056 set { submitted = value; }
00057 }
00058
00062 public List<Reference> References
00063 {
00064 get { return references; }
00065 }
00066
00070 public List<Role> Roles
00071 {
00072 get { return roles; }
00073 }
00074
00078 public string Synopsis
00079 {
00080 get { return synopsis; }
00081 set { synopsis = value; }
00082 }
00083
00087 public string Department
00088 {
00089 get { return department; }
00090 set { department = value; }
00091 }
00092
00096 public string Title
00097 {
00098 get { return title; }
00099 set { title = value; }
00100 }
00101
00105 public string Subject
00106 {
00107 get { return subject; }
00108 set { subject = value; }
00109 }
00110
00114 public DateTime EndDate
00115 {
00116 get { return endDate; }
00117 set { endDate = value; }
00118 }
00119
00123 public DateTime StartDate
00124 {
00125 get { return startDate; }
00126 set { startDate = value; }
00127 }
00128
00134 public Role GetPerson(string username)
00135 {
00136 foreach (Role r in roles)
00137 {
00138 if (r.Person.UserName == username)
00139 {
00140 return r;
00141 }
00142 }
00143 return null;
00144 }
00145
00151 public void AddPerson(Person person, RoleType role)
00152 {
00153 Role r = GetPerson(person.UserName);
00154 if (r == null)
00155 roles.Add(new Role(person, role, this));
00156 else if(r.Type != RoleType.Creator)
00157 r.Type = role;
00158 }
00159
00163 public ProjectInfo Info
00164 {
00165 get
00166 {
00167 return new ProjectInfo(ID, startDate, endDate, subject, title, department, synopsis, submitted);
00168 }
00169 }
00170
00176 public static Project FromInfo(ProjectInfo info)
00177 {
00178 Project p = new Project(info.id, info.startDate, info.endDate, info.subject, info.title, info.department, info.synopsis, info.submitted);
00179 return p;
00180 }
00181 }
00182
00183 }