Example #1
0
        private void AddWorkerButton_Click(object sender, RoutedEventArgs e)
        {
            Worker worker = new Worker();

            worker.Name              = this.name.Text;
            worker.DepartamentID     = departamentRepositoty.Get(p => p.Name == this.departament.Text).Select(p => p.ID).First();
            worker.BirthPlace        = this.birthPlace.Text;
            worker.Surname           = surname.Text;
            worker.Patronymic        = patronymic.Text;
            worker.RegistrationPlace = registrationPlace.Text;
            worker.BirthPlace        = birthPlace.Text;
            worker.DateOfBirth       = (DateTime)dateOfBirth.SelectedDate;
            worker.Nationality       = nationality.Text;
            worker.Education         = education.Text;
            worker.Sex           = sex.Text == "мужской" ? true : false;
            worker.MaritalStatus = maritalStatus.Text == "холост" ? true : false;
            worker.PhoneNum      = phoneNum.Text;
            worker.Email         = email.Text;

            workerRepositoty.Insert(worker);
            workerRepositoty.AddToCache(worker, worker.ID);

            if (contractListView.Items != null)
            {
                for (int i = 0; i < contractListView.Items.Count; i++)
                {
                    Items    Value = (Items)contractListView.Items[i];
                    Contract cnt   = new Contract();

                    cnt.ContractTypeId   = contractTypeRepositoty.Get(p => p.Name == Value.typeName).First().ID;
                    cnt.BeginningDate    = Value.beginDate;
                    cnt.EndDate          = Value.endDate;
                    cnt.WorkerId         = worker.ID;
                    cnt.OrderNum         = Value.OrderNum;
                    cnt.ArtistCategoryId = artistCategoryRepositoty.Get(p => p.Name == Value.artistCategory).First().ID;
                    cnt.Position         = Value.Position;

                    contractRepositoty.Insert(cnt);
                }
            }

            MessageBox.Show("добавлен");
            Close_Click(sender, e);
        }
Example #2
0
 public void Create(Worker entity)
 {
     _repository.Insert(entity);
 }