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));
            }
        }
        public ActionResult Create([Bind(Include = "Id,FirstName,LastName,BirthDay,BirthPlace")] PeopleViewModel peopleViewModel)
        {
            if (ModelState.IsValid)
            {
                peopleViewModel.Id = Guid.NewGuid();
                People people = Mapper.Map <PeopleViewModel, People>(peopleViewModel);
                _service.AddPeople(people);
                return(RedirectToAction("Index"));
            }

            return(View(peopleViewModel));
        }
 public async Task <PeopleModel> Post([FromBody] PeopleModel model)
 {
     return(await _service.AddPeople(model));
 }
 public IActionResult AddPeople(PeopleViewModel people)
 {
     _peopleService.AddPeople(people);
     return(Ok());
 }