public void Update(Guid oldPersonID, Person newPerson)
        {
            using (var db = new EducationCourses())
            {
                Person oldPerson = db.Persons.SingleOrDefault(person => person.ID == oldPersonID);
                oldPerson.Name = newPerson.Name;
                oldPerson.Family = newPerson.Family;
                oldPerson.Account = newPerson.Account;
                oldPerson.Address = newPerson.Address;
                oldPerson.BirthDay = newPerson.BirthDay;
                oldPerson.Type = newPerson.Type;
                oldPerson.Tel = newPerson.Tel;
                oldPerson.Cities_ID = newPerson.Cities_ID;
                oldPerson.Tel = newPerson.Tel;
                oldPerson.Gender = newPerson.Gender;
                oldPerson.Level = newPerson.Level;
                oldPerson.Gender = newPerson.Gender;
                oldPerson.NationalCode = newPerson.NationalCode;
                db.SaveChanges();
                if (this.PersonUpdated != null)
                    this.PersonUpdated(this, new CustomEventArgs<Person>(newPerson));
            }


        }
 public void Insert(Course course,Person student)
 {
     using (var db=new EducationCourses())
     {
         db.MemberShips.Add(new MemberShip {ID=Guid.NewGuid(), Courses_ID = course.ID, Persons_ID = student.ID, 
             MemberShipDate = PersianDateTime.Now.Date.ToString().Substring(0,10)});
         db.SaveChanges();
     }
 }
 public void Delete(Person person)
 {
     using (var db=new EducationCourses())
     {
         db.Persons.Remove(db.Persons.SingleOrDefault(p => p.ID == person.ID));
         db.SaveChanges();
         if (this.PersonDeleted != null)
             this.PersonDeleted(this, new CustomEventArgs<Person>(person));
     }
 }
 public void Insert(Model.Person person)
 {
     using (var db = new EducationCourses())
     {
         db.Persons.Add(person);
         db.SaveChanges();
         if (this.PersonAdded != null)
             this.PersonAdded(this, new CustomEventArgs<Person>(person));
     }
 }
 public void Delete(Model.Course course)
 {
     using (var db = new EducationCourses())
     {
         db.Courses.Attach(course);
         db.Courses.Remove(course);
         db.SaveChanges();
         if (this.CourseDeleted != null)
             this.CourseDeleted(this, new CustomEventArgs<Course>(course));
     }
 }
 public void Delete(Model.Location location)
 {
     using (var db = new EducationCourses())
     {
         db.Locations.Attach(location);
         db.Locations.Remove(location);
         db.SaveChanges();
         if (this.Deleted != null)
             this.Deleted(this, new CustomEventArgs<Location>(location));
     }
 }
 public void Insert(Model.Location location)
 {
     using (var db=new EducationCourses())
     {
         location.ID = Guid.NewGuid();
         db.Locations.Add(location);
         db.SaveChanges();
         if (this.Added != null)
             this.Added(this, new CustomEventArgs<Location>(location));
     }
 }
 public void Insert(string name)
 {
     using (var db=new EducationCourses())
     {
         Lesson lesson = new Lesson { ID = Guid.NewGuid(), Name = name };
         db.Lessons.Add(lesson);
         db.SaveChanges();
         if (this.LessonAdded != null)
             this.LessonAdded(this, new CustomEventArgs<Lesson>(lesson));
     }
 }
 public void Insert(Model.Course course)
 {
     using (var db = new EducationCourses())
     {
         course.Location = null;
         course.Lesson = null;
         course.Person = null;
         db.Courses.Add(course);
         db.SaveChanges();
         if (this.CourseAdded != null)
             this.CourseAdded(this, new CustomEventArgs<Course>(course));
     }
 }
 public void Update(Model.Course course, Guid id)
 {
     using (var db = new EducationCourses())
     {
         Course temp = db.Courses.Find(id);
         temp.LengthClassTime = course.LengthClassTime;
         temp.Lessons_ID = course.Lesson.ID;
         temp.Persons_ID = course.Person.ID;
         temp.StartTime = course.StartTime;
         temp.Duration = course.Duration;
         temp.Locations_ID = course.Location.ID;
         temp.Cost = course.Cost;
         temp.Capacity = course.Capacity;
         temp.LengthClassTime = course.LengthClassTime;
         db.SaveChanges();
         if (this.CourseUpdated != null)
             this.CourseUpdated(this, new CustomEventArgs<Course>(temp));
     }
 }