예제 #1
0
        private bool ValidatePeople(PeopleDTO peopleDto)
        {
            if (string.IsNullOrEmpty(peopleDto.FirstName))
            {
                return(false);
            }

            if (string.IsNullOrEmpty(peopleDto.LastName))
            {
                return(false);
            }

            if (string.IsNullOrEmpty(peopleDto.SecondName))
            {
                return(false);
            }

            if (peopleDto.DateBirthday == DateTime.MinValue)
            {
                return(false);
            }

            if (string.IsNullOrEmpty(peopleDto.Email))
            {
                return(false);
            }

            return(true);
        }
예제 #2
0
        public IEnumerable <PeopleDTO> GetPeoples()
        {
            // Применяем автомаппер для проекции одной коллекции на другую.
            var peoplesTask   = Task.Factory.StartNew(() => database.Peoples.GetAll());
            var peoplesResult = new List <PeopleDTO>();
            var mapper        = new MapperConfiguration(cfg => cfg.CreateMap <Phone, PhoneDTO>()).CreateMapper();

            foreach (var people in peoplesTask.Result)
            {
                var phones    = mapper.Map <IEnumerable <Phone>, List <PhoneDTO> >(people.Phones);
                var peopleDTO = new PeopleDTO
                {
                    Id           = people.Id,
                    FirstName    = people.FirstName,
                    LastName     = people.LastName,
                    SecondName   = people.SecondName,
                    Email        = people.Email,
                    DateBirthday = people.DateBirthday,
                    Phones       = phones
                };
                peoplesResult.Add(peopleDTO);
            }

            return(peoplesResult);
        }
예제 #3
0
        public JsonResult GetPeoples()
        {
            var response = WebHostCache.Current.GetResponse <XElement>(@"api\Dictionary\GetPeoples?sessionKey=" + session.Key.ToString());
            var result   = PeopleDTO.ArrayFromXElement(response).ToList();

            return(Json(new { rc = 0, Items = result }, JsonRequestBehavior.AllowGet));
        }
예제 #4
0
 /// <summary>
 /// Xuất bảng lương nhân viên
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void btSave_Click_1(object sender, EventArgs e)
 {
     if (txtFN.Text != "")
     {
         PeopleDTO nv = new PeopleDTO();
         Salary    sl = null;
         for (int i = 0; i < tbNV.Rows.Count; i++)
         {
             if (tbNV.Rows[i]["Id"].ToString() == cbbIDP.Text.Substring(0, cbbIDP.Text.Length - 3))
             {
                 nv.ID    = Int32.Parse(tbNV.Rows[i]["Id"].ToString());
                 nv.KH    = tbNV.Rows[i]["Kh"].ToString();
                 nv.FName = tbNV.Rows[i]["FName"].ToString();
                 nv.LName = tbNV.Rows[i]["LName"].ToString();
                 nv.MaCV  = Int32.Parse(tbNV.Rows[i]["Id"].ToString());
                 sl       = new Salary(nv);
                 sl.CV    = cbbCV.Text;
                 sl.Luong = luongNV;
                 break;
             }
         }
         sl.ShowDialog();
     }
     else
     {
         MessageBox.Show("Chưa nhập đủ thông tin", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
예제 #5
0
 /// <summary>
 /// Lưu KTKL cho nhân viên
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void btSave_Click(object sender, EventArgs e)
 {
     if (txtN.Text != "" && txtKLKT.Text != "")
     {
         PeopleDTO pp = new PeopleDTO();
         KTKLDTO   kt = new KTKLDTO();
         kt.ID = Int32.Parse(cbbKTKL.Text);
         pp.ID = Int32.Parse(cbbID.Text.Substring(0, cbbID.Text.Length - 3));
         pp.KH = cbbID.Text.Substring(cbbID.Text.Length - 3);
         int result = ketoan.ThemNVKTKL(kt, pp);
         if (result > 0)
         {
             MessageBox.Show("Thành công", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
             this.Close();
         }
         else
         {
             MessageBox.Show("Không thành công", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
         }
     }
     else
     {
         MessageBox.Show("Chưa nhập đủ thông tin", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
예제 #6
0
        public static List <PeopleDTO> loadListTeacher(string status)
        {
            string sCommand = "";

            if (status == "System.Windows.Controls.ComboBoxItem: Active")
            {
                sCommand = @"Select* from Teacher where isActive = 'T'";
            }
            else if (status == "System.Windows.Controls.ComboBoxItem: Deactive")
            {
                sCommand = @"Select* from Teacher where isActive = 'F'";
            }
            else
            {
                sCommand = @"Select* from Teacher";
            }
            con = DataProvider.OpenConnection();
            DataTable dt = DataProvider.GetDataTable(sCommand, con);

            if (dt.Rows.Count <= 0)
            {
                DataProvider.CloseConnection(con);
                return(null);
            }
            else
            {
                List <PeopleDTO> result = new List <PeopleDTO>();
                int n = dt.Rows.Count;
                for (int i = 0; i < n; i++)
                {
                    PeopleDTO teacher = new PeopleDTO();
                    teacher.Id         = dt.Rows[i]["IDTeacher"].ToString();
                    teacher.Name       = dt.Rows[i]["Name"].ToString();
                    teacher.Gender     = dt.Rows[i]["Gender"].ToString();
                    teacher.Email      = dt.Rows[i]["Email"].ToString();
                    teacher.DateofBith = dt.Rows[i]["BirthDay"].ToString();
                    if (dt.Rows[i]["TypeTeacher"].ToString() == "PDT")
                    {
                        teacher.Type = "AAO Staff";
                    }
                    else
                    {
                        teacher.Type = "Teacher";
                    }
                    teacher.Password = dt.Rows[i]["Password"].ToString();
                    teacher.Phone    = dt.Rows[i]["Phone"].ToString();
                    if (dt.Rows[i]["isActive"].ToString() == "T")
                    {
                        teacher.Status = "Active";
                    }
                    else
                    {
                        teacher.Status = "Deactive";
                    }
                    result.Add(teacher);
                }
                DataProvider.CloseConnection(con);
                return(result);
            }
        }
예제 #7
0
        public void GetNhanVienDTO(out PeopleDTO Nv, object Id)
        {
            Nv = new PeopleDTO();
            Providers     provi  = new Providers();
            SqlDataReader reader = provi.GetNhanVienDTO(Id);

            if (reader.Read())
            {
                Nv.ID       = int.Parse(reader["Id"].ToString());
                Nv.FName    = reader["Fname"].ToString();
                Nv.LName    = reader["LName"].ToString();
                Nv.GioiTinh = reader["GioiTinh"].ToString();
                Nv.KH       = reader["Kh"].ToString();
                Nv.DOB      = DateTime.Parse(reader["DOB"].ToString());
                Nv.HD       = DateTime.Parse(reader["HireDay"].ToString());
                Nv.QueQuan  = reader["QueQuan"].ToString();
                Nv.MaPB     = int.Parse(reader["Id_PB"].ToString());
                Nv.MaCV     = int.Parse(reader["Id_CV"].ToString());
                if (reader["Id_NQL"] != DBNull.Value)
                {
                    Nv.IDNQL = int.Parse(reader["Id_NQL"].ToString());
                }
                if (reader["Kh_NQL"] != DBNull.Value)
                {
                    Nv.KHNQL = reader["Kh_NQL"].ToString();
                }
            }
            reader.Close();
        }
예제 #8
0
        private void SelectItem(object sender, MouseButtonEventArgs e)
        {
            PeopleDTO item = (PeopleDTO)listviewUser.SelectedItems[0];

            fullname_user_infor.Text     = item.Name;
            birthofday_user_infor.Text   = item.DateofBith;
            email_user_infor.Text        = item.Email;
            password_user_infor.Password = item.Password;
            if (item.Gender == "Male")
            {
                gender_user_infor.SelectedIndex = 1;
            }
            else if (item.Gender == "Female")
            {
                gender_user_infor.SelectedIndex = 2;
            }
            else
            {
                gender_user_infor.SelectedIndex = 0;
            }
            phone_user_infor.Text  = item.Phone;
            author_user_infor.Text = item.Type;
            if (item.Type == "Student")
            {
                if (item.Status == "Active")
                {
                    btnDelete.Visibility = Visibility.Visible;
                }
                else if (item.Status == "Deactive")
                {
                    btnActive.Visibility = Visibility.Visible;
                }
            }
        }
예제 #9
0
        private void btnActive_Click(object sender, RoutedEventArgs e)
        {
            PeopleDTO item = (PeopleDTO)listviewUser.SelectedItems[0];

            if (!AdminBUS.ActiveUser(item.Id, item.Type))
            {
                MessageBox.Show("Error", "Active user failed", MessageBoxButton.OK, MessageBoxImage.Error);
            }
            if (chooseAuthor.SelectedValue.ToString() == "System.Windows.Controls.ComboBoxItem: Student")
            {
                listviewUser.ItemsSource = AdminBUS.loadListStudent(chooseStatus.SelectedValue.ToString());
            }
            else if (chooseAuthor.SelectedValue.ToString() == "System.Windows.Controls.ComboBoxItem: Teacher")
            {
                listviewUser.ItemsSource = AdminBUS.loadListTeacher(chooseStatus.SelectedValue.ToString());
            }
            else
            {
                listviewUser.ItemsSource = AdminBUS.loadListUser(chooseStatus.SelectedValue.ToString());
            }


            btnDelete.Visibility = Visibility.Collapsed;
            btnActive.Visibility = Visibility.Collapsed;
            btnEdit.IsEnabled    = false;
        }
예제 #10
0
        private bool ValidatePeople(PeopleDTO peopleDto)
        {
            if (string.IsNullOrEmpty(peopleDto.FirstName))
            {
                throw new ValidationException("имя пустое", "Firstname");
            }

            if (string.IsNullOrEmpty(peopleDto.LastName))
            {
                throw new ValidationException("фамилия пустая", "Lastname");
            }

            if (string.IsNullOrEmpty(peopleDto.SecondName))
            {
                throw new ValidationException("отчество пустое", "Secondname");
            }

            if (string.IsNullOrEmpty(peopleDto.Phone))
            {
                throw new ValidationException("телефон пустой", "Phone");
            }

            if (peopleDto.DateBirthday == null)
            {
                throw new ValidationException("дата рождения не задана", "DateBirthday");
            }

            if (string.IsNullOrEmpty(peopleDto.Email))
            {
                throw new ValidationException("Email пустой", "Email");
            }
            return(true);
        }
        public JsonResult AddPeopleJSON(PeopleViewModel people)
        {
            try
            {
                var peopleDto = new PeopleDTO
                {
                    Id           = people.Id,
                    FirstName    = people.FirstName,
                    LastName     = people.LastName,
                    SecondName   = people.SecondName,
                    Email        = people.Email,
                    Phone        = people.Phone,
                    DateBirthday = people.DateBirthday
                };

                if (people.Id > 0)
                {
                    peopleService.EditPeople(peopleDto);
                }
                else
                {
                    peopleService.AddPeople(peopleDto);
                }
                return(Json(new { success = true, data = people }, JsonRequestBehavior.AllowGet));
            }
            catch (ValidationException ex)
            {
                ModelState.AddModelError(ex.Property, ex.Message);
                return(Json(new { success = false, errorstring = ex.Message }, JsonRequestBehavior.AllowGet));
            }
        }
예제 #12
0
        public async Task <JsonResult> AddPeopleJSON(PeopleViewModel people)
        {
            try
            {
                var peopleDto = new PeopleDTO
                {
                    Id           = people.Id,
                    FirstName    = people.FirstName,
                    LastName     = people.LastName,
                    SecondName   = people.SecondName,
                    Email        = people.Email,
                    DateBirthday = people.DateBirthday
                };

                if (people.Id > 0)
                {
                    await peopleService.EditPeopleTask(peopleDto);
                }
                else
                {
                    var result = await peopleService.AddPeopleTask(peopleDto);

                    if (!result.Successed)
                    {
                        return(Json(new { success = false, Message = result.ErrorMessage }, JsonRequestBehavior.AllowGet));
                    }

                    people.Id = result.Id;
                }

                foreach (var phone in people.Phones)
                {
                    if (phone.ForDelete && phone.Id > 0)
                    {
                        await peopleService.DelPhoneForPeopleTask(phone.Id, people.Id);
                    }

                    if (phone.Id == 0 && !phone.ForDelete)
                    {
                        await peopleService.AddPhoneForPeopleTask(phone.PhoneNumber, people.Id);
                    }

                    if (!phone.ForDelete && phone.Id > 0)
                    {
                        await peopleService.EditPhoneForPeopleTask(phone.Id, people.Id, phone.PhoneNumber);
                    }
                }

                return(Json(new { success = true, data = people }, JsonRequestBehavior.AllowGet));
            }
            catch (ValidationException ex)
            {
                ModelState.AddModelError(ex.Property, ex.Message);
                return(Json(new { success = false, errorstring = ex.Message }, JsonRequestBehavior.AllowGet));
            }
        }
예제 #13
0
        //public void AddSubject(Subject newSubject)
        //{
        //    _context.Add(newSubject);
        //    _context.SaveChanges();
        //}

        public async Task <PeopleDTO> GetPeopleAsync()
        {
            var people = new PeopleDTO();

            people.admins = await Task.Run(() => _context.Admins);

            people.students = await Task.Run(() => _context.Students.Include(s => s.Class));

            people.teachers = await Task.Run(() => _context.Teachers);

            return(people);
        }
예제 #14
0
 /// <summary>
 ///Truyền dữ liệu vào User peple và User thannhan
 /// </summary>
 /// <param name="people">Đối tượng people được đưa vào</param>
 /// <param name="pb">danh sách phòng ban</param>
 /// <param name="thongbao">xử lý được chọn</param>
 /// <param name="changed">cờ để kiểm tra có gán các giá trị mặt định cho nhan vien hay không</param>
 public void TranslationPeople(PeopleDTO people, List <PhongBanDTO> pb, string thongbao, bool changed)
 {
     this.Text           = thongbao;
     StringThongBao      = thongbao;
     ppus.StringThongBao = thongbao;
     ppus.Visiblenew     = changed;
     nhanVien            = people;
     ppus.NhanVien       = nhanVien;
     ppus.LPB            = pb;
     tnus1.Temp          = stringThongBao;
     tnus1.BinDing();
 }
예제 #15
0
        public void AddPeopleByNullDateBirthdayTest()
        {
            PeopleDTO pdto = new PeopleDTO();

            pdto.FirstName  = "qqqq";
            pdto.LastName   = "eeee";
            pdto.SecondName = "wwww";
            pdto.Email      = "*****@*****.**";

            var result = peopleserv.AddPeople(pdto);

            Assert.AreEqual(result.ErrorMessage, "validation error");
        }
예제 #16
0
        public void EditPeopleByEmptyEmailTest()
        {
            PeopleDTO pdto = new PeopleDTO();

            pdto.FirstName    = "qqqq";
            pdto.LastName     = "eeee";
            pdto.SecondName   = "wwww";
            pdto.Email        = "";
            pdto.DateBirthday = DateTime.Now;

            var result = peopleserv.EditPeople(pdto);

            Assert.AreEqual(result.ErrorMessage, "validation error");
        }
예제 #17
0
        private void btAdd_Click(object sender, EventArgs e)
        {
            PeopleDTO people = new PeopleDTO();
            Form4     f4     = new Form4(true);

            f4.TranslationPeople(people, listPhongBan, "Add", true);
            f4.ShowDialog();
            txttrang2.Text = null;
            txttrang2.Text = txtTrang.Text;
            if (txtTrang.Text == "")
            {
                soTrang        = 1;
                txttrang2.Text = 1.ToString();
            }
        }
예제 #18
0
        private void btnDoneofEdit_click(object sender, RoutedEventArgs e)
        {
            PeopleDTO item = (PeopleDTO)listviewUser.SelectedItems[0];

            if (!AdminBUS.resetPassword(item.Id, password_user_infor.Password, item.Type))
            {
                MessageBox.Show("Change password failed");
                return;
            }

            btnEdit.Visibility            = Visibility.Visible;
            btnDoneOfEdit.Visibility      = Visibility.Collapsed;
            password_user_infor.IsEnabled = false;
            btnCancel.Visibility          = Visibility.Collapsed;
        }
예제 #19
0
        public void AddPeopleTest()
        {
            PeopleDTO pdto = new PeopleDTO();

            pdto.FirstName    = "qqqq";
            pdto.LastName     = "eeee";
            pdto.SecondName   = "wwww";
            pdto.Email        = "*****@*****.**";
            pdto.DateBirthday = DateTime.Now;

            var result = peopleserv.AddPeople(pdto);

            peopleserv.DelPeople(result.Id);
            Assert.AreEqual(result.Successed, true);
        }
예제 #20
0
        public async Task <IActionResult> OnGetAsync(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            PeopleDTO = await _context.PeopleDTO.FirstOrDefaultAsync(m => m.Id == id);

            if (PeopleDTO == null)
            {
                return(NotFound());
            }
            return(Page());
        }
예제 #21
0
        /// <summary>
        /// Thêm nhân viên
        /// </summary>
        /// <param name="pp">đối tượng Nhân viên DTO</param>
        /// <returns></returns>
        public int ThemNhanVien(PeopleDTO pp)
        {
            Providers provi = new Providers();
            int       kq    = provi.ThemNhanVien(pp.KH, pp.FName, pp.LName, pp.GioiTinh, pp.DOB, pp.HD, pp.QueQuan, pp.MaPB, pp.IDNQL, pp.KHNQL, pp.MaCV);

            if (kq >= 0)
            {
                return(kq);
            }
            else
            {
                MessageBox.Show("Xử lý lổi", "Error");
                return(-1);
            }
        }
예제 #22
0
        public async Task <IActionResult> OnPostAsync(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            PeopleDTO = await _context.PeopleDTO.FindAsync(id);

            if (PeopleDTO != null)
            {
                _context.PeopleDTO.Remove(PeopleDTO);
                await _context.SaveChangesAsync();
            }

            return(RedirectToPage("./Index"));
        }
예제 #23
0
 public void EditPeople(PeopleDTO peopleDto)
 {
     if (ValidatePeople(peopleDto))
     {
         var people = this.database.Peoples.Get(peopleDto.Id);
         people.FirstName    = peopleDto.FirstName;
         people.LastName     = peopleDto.LastName;
         people.SecondName   = peopleDto.SecondName;
         people.Email        = peopleDto.Email;
         people.Phone        = peopleDto.Phone;
         people.DateBirthday = peopleDto.DateBirthday;
         this.database.Peoples.Update(people);
         EventChanges = new EditOperation(EventChanges);
         EventChanges.AddOperation();
         Save();
     }
 }
예제 #24
0
        static void Main(string[] args)
        {
            Console.WriteLine("Hello World!");

            var client   = new MongoClient("mongodb://localhost:27017");
            var database = client.GetDatabase("school");

            var peopleDB = database.GetCollection <People>("people");

            var people = new People()
            {
                Id     = "6089d0ab6c3db54c32838b99",
                Edad   = 30,
                Nombre = "oscar cortez villca"
            };

            // peopleDB.InsertOne(people);

            List <People> lstPeople = peopleDB.Find(d => true).ToList();

            lstPeople.ForEach(person =>
            {
                Console.WriteLine($"id: {person.Id}, Nombre: {person.Nombre} Edad: {person.Edad}");
            });

            //peopleDB.ReplaceOne(
            //    d => d.Id == "6089d0ab6c3db54c32838b99",
            //    people
            //);

            //peopleDB.DeleteOne(d => d.Id == "6089d0ab6c3db54c32838b99");

            MapperConfiguration PeopleConfig = new MapperConfiguration(cfg =>
                                                                       cfg.CreateMap <People, PeopleDTO>()
                                                                       );
            // and if the attribute name is different
            // . ForMember ( dest = > dest. FullName , act = > act. MapFrom ( src = > src. Name ))
            Mapper    mapper     = new Mapper(PeopleConfig);
            PeopleDTO peopleDTO2 = mapper.Map <People, PeopleDTO>(people);

            //var peopleDTO = mapper.Map<PeopleDTO>(people);

            Console.WriteLine($"nombre: {peopleDTO2.Nombre}, edad: {peopleDTO2.Edad}, id: {peopleDTO2.Id}");
        }
예제 #25
0
        public async Task <XElement> GetPeoples(string sessionKey, long requestId)
        {
            #region Заглушка
            var hubConn  = new HubConnection(Settings.Default.ResponseHubUrl);
            var hubProxy = hubConn.CreateHubProxy("ResponseHub");
            await hubConn.Start();

            var result = PeopleDTO.ArrayToXElement(new PeopleDTO[]
            {
                new PeopleDTO()
                {
                    Id   = Guid.NewGuid(),
                    Name = "Артем Аленин",
                },
                new PeopleDTO()
                {
                    Id   = Guid.NewGuid(),
                    Name = "Иванов Александр",
                },
                new PeopleDTO()
                {
                    Id   = Guid.NewGuid(),
                    Name = "Денис Стенюшкин"
                },
                new PeopleDTO()
                {
                    Id   = Guid.NewGuid(),
                    Name = "Малышева Ирина"
                },
                new PeopleDTO()
                {
                    Id   = Guid.NewGuid(),
                    Name = "Валерий Рябов"
                }
            });
            result.Add(new XElement("rc", 0));
            result.Add(new XElement("msg", ""));


            hubProxy.Invoke("OperationCallback", sessionKey, requestId, result);
            return(zapad.Model.API.ReturnCodes.BuildRcAnswer(0, "Успешно"));

            #endregion
        }
예제 #26
0
        public PeopleDTO AddPeople(PeopleDTO peopleDto)
        {
            if (peopleDto == null)
            {
                return(new PeopleDTO
                {
                    Successed = false,
                    ErrorMessage = "People not be null"
                });
            }

            if (ValidatePeople(peopleDto))
            {
                People people = new People
                {
                    FirstName    = peopleDto.FirstName,
                    LastName     = peopleDto.LastName,
                    SecondName   = peopleDto.SecondName,
                    DateBirthday = peopleDto.DateBirthday,
                    Email        = peopleDto.Email
                };

                var peopleRes = this.database.Peoples.Create(people);
                this.EventChanges = new AddingOperation(EventChanges);
                this.EventChanges.AddOperation(peopleRes.Id);
                Save();
                return(new PeopleDTO
                {
                    Id = peopleRes.Id,
                    FirstName = peopleRes.FirstName,
                    LastName = peopleRes.LastName,
                    SecondName = peopleRes.SecondName,
                    Email = peopleRes.Email,
                    DateBirthday = peopleRes.DateBirthday,
                    Successed = true
                });
            }
            return(new PeopleDTO
            {
                Successed = false,
                ErrorMessage = "validation error"
            });
        }
예제 #27
0
        public void AddPeople(PeopleDTO peopleDto)
        {
            if (ValidatePeople(peopleDto))
            {
                People people = new People
                {
                    FirstName    = peopleDto.FirstName,
                    LastName     = peopleDto.LastName,
                    SecondName   = peopleDto.SecondName,
                    DateBirthday = peopleDto.DateBirthday,
                    Email        = peopleDto.Email,
                    Phone        = peopleDto.Phone
                };

                this.database.Peoples.Create(people);
                EventChanges = new AddingOperation(EventChanges);
                EventChanges.AddOperation();
                Save();
            }
        }
예제 #28
0
        public async Task <IActionResult> GetById(int id)
        {
            if (id == 0)
            {
                return(BadRequest());
            }

            People people = await _peopleUseCase.GetById(id);

            if (people == null)
            {
                return(NotFound());
            }

            List <Car> car = await _carUseCase.GetCarsByPeopleId(id);

            PeopleDTO peopleDTO = PeopleMapper.MapperModelToDTO(people, car);

            return(Ok(peopleDTO));
        }
예제 #29
0
        public PeopleDTO EditPeople(PeopleDTO peopleDto)
        {
            if (peopleDto == null)
            {
                return new PeopleDTO
                       {
                           Successed    = false,
                           ErrorMessage = "People not be null"
                       }
            }
            ;

            if (this.ValidatePeople(peopleDto))
            {
                var peopleTask = Task.Factory.StartNew(() => this.database.Peoples.Get(peopleDto.Id));

                var people = peopleTask.Result;
                people.FirstName    = peopleDto.FirstName;
                people.LastName     = peopleDto.LastName;
                people.SecondName   = peopleDto.SecondName;
                people.Email        = peopleDto.Email;
                people.DateBirthday = peopleDto.DateBirthday;
                this.database.Peoples.Update(people);
                this.EventChanges = new EditOperation(EventChanges);
                this.EventChanges.AddOperation(people.Id);
                Save();

                peopleDto.Successed = true;
                return(peopleDto);
            }

            return(new PeopleDTO
            {
                Successed = false,
                ErrorMessage = "validation error"
            });
        }
예제 #30
0
        public IEnumerable <PeopleDTO> FindPeoples(string filter)
        {
            var peoplesTask   = Task.Factory.StartNew(() => database.Peoples.Find(p => findFynction(p, filter)));
            var peoplesResult = new List <PeopleDTO>();
            var mapper        = new MapperConfiguration(cfg => cfg.CreateMap <Phone, PhoneDTO>()).CreateMapper();

            foreach (var people in peoplesTask.Result)
            {
                var phones    = mapper.Map <IEnumerable <Phone>, List <PhoneDTO> >(people.Phones);
                var peopleDTO = new PeopleDTO
                {
                    Id           = people.Id,
                    FirstName    = people.FirstName,
                    LastName     = people.LastName,
                    SecondName   = people.SecondName,
                    Email        = people.Email,
                    DateBirthday = people.DateBirthday,
                    Phones       = phones
                };
                peoplesResult.Add(peopleDTO);
            }

            return(peoplesResult);
        }