FacultyModel.cs CampusAppWP8::Model::Departments::FacultyModel CampusAppWP8::Model::Departments //----------------------------------------------------------------------- //<copyrightfile="FacultyModel.cs"company="BTU/IIT"> //Companycopyrighttag. //</copyright> //<author>fiedlchr</author> //<sience>24.06.2013</sience> //---------------------------------------------------------------------- namespaceCampusAppWP8.Model.Departments { usingSystem.Collections.ObjectModel; usingSystem.Xml.Serialization; usingCampusAppWP8.Resources; publicclassFacultyModel { privateObservableCollection<ChairModel>chairs; privatestringname=string.Empty; privateboolhasChanged=false; publicFacultyModel() { this.chairs=newObservableCollection<ChairModel>(); } publicFacultyModel(stringname) { this.name=name; this.chairs=newObservableCollection<ChairModel>(); } [XmlElement("chair")] publicObservableCollection<ChairModel>Chairs { get { returnthis.chairs; } set { if(value!=this.chairs) { this.chairs=value; } } } publicstringName { get { returnAppResources.Faculty+""+this.name; } } [XmlAttribute("id")] publicstringId { get { returnthis.name; } set { this.name=value; } } publicboolRemoveChair(stringchairName) { boolretValue=false; ChairModeltempChair=null; foreach(ChairModeltempinthis.Chairs) { if(temp.Name.Equals(chairName)==true) { tempChair=temp; } } if(tempChair!=null) { retValue=this.Chairs.Remove(tempChair); this.hasChanged=true; } returnretValue; } publicboolAddChair(ChairModelchairModel) { boolretValue=false; if((chairModel!=null) &&(this.Chairs.Contains(chairModel)==false)) { boolisIn=false; foreach(ChairModeltempinthis.Chairs) { if((temp.NameDE.Equals(chairModel.NameDE)==true) ||(temp.NameEN.Equals(chairModel.NameEN)==true)) { isIn=true; } } if(isIn==false) { this.Chairs.Add(chairModel); this.hasChanged=true; retValue=true; } } returnretValue; } publicboolAddChair(stringnameDE,stringnameEN,stringurl) { boolretValue=false; boolisIn=false; foreach(ChairModeltempinthis.Chairs) { if((temp.NameDE.Equals(nameDE)==true) ||(temp.NameEN.Equals(nameEN)==true)) { isIn=true; } } if(isIn==false) { ChairModelnewModel=newChairModel(); newModel.NameDE=nameDE; newModel.NameEN=nameEN; newModel.Url=url; this.Chairs.Add(newModel); this.hasChanged=true; retValue=true; } returnretValue; } publicChairModelGetChairModel(stringname) { ChairModelretValue=null; foreach(ChairModeltempinthis.Chairs) { if(temp.Name.Equals(name)==true) { retValue=temp; } } returnretValue; } publicboolHasChanged(boolreset=true) { boolretValue=this.hasChanged; if(reset==true) { this.hasChanged=false; } returnretValue; } } }