コード例 #1
0
        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));
            }


        }
コード例 #2
0
        /// <summary>
        /// سازنده پیش فرض کلاس مدیریت اشخاص 
        /// که در این سازنده به مسیچ ها نیز پاسخ داده میشود
        /// </summary>
        public PersonViewModel()
        {
            #region Messages
            // عضو شدن به مسیچ ویرایش کردن
            Messenger.Default.Register<Person>(this,
           "edit person",
           x =>
           {
               _currentPerson = x;
               this.ActionMode = Mode.Edit;
               this._orginal = (PersonViewModel)this.MemberwiseClone();
           });
            //عضو شدن به مسیج افزودن کاربر
            Messenger.Default.Register<Person>(this,
          "insert person",
          x =>
          {
              FireValidationForInsert();
              _currentPerson = x;
              this.ActionMode = Mode.Add;
          });
            #endregion Messages

            this._repository = PersonsListViewModel._repository;
            this._cities = null;
            this.CancelCommand = new RelayCommand(()=>this.Cancel());
        }
コード例 #3
0
 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();
     }
 }
コード例 #4
0
 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));
     }
 }
コード例 #5
0
        private void Add()
        {
            try
            {
                this._repository.Insert(this.SelectedCourse, this.SelectedStudent);
                this._selectedStudent = null;
                this._selectedCourse = null;
                base.OnPropertyChanged("SelectedCourse");
                base.OnPropertyChanged("SelectedStudent");
                this._courses.Clear();
                this._courses = new ObservableCollection<Course>(this._repository.SelectAllCourses());
                base.OnPropertyChanged("Courses");

            }
            catch
            {
            }
        }
コード例 #6
0
 private void Delete(Person person)
 {
     try
     {
         _repository.Delete(person);
         this.GetPersons("", "Name");
         this.Persons = this._persons;
     }
     catch 
     {  }
 }
コード例 #7
0
 /// <summary>
 /// متدی برای کامند ویرایش شخص
 /// </summary>
 /// <param name="person">شخص</param>
 private void Edit(Person person)
 {
     {
         if (person == null)
             return;
         Messenger.Default.Send(person, "edit persons");
     }
 }