예제 #1
0
        public void Update(PeopleVM peopleVM)
        {
            var model         = mapper.Map <People>(peopleVM);
            var updateCommand = mapper.Map <UpdatePeopleCommand>(model);

            bus.SendCommand(updateCommand);
        }
예제 #2
0
        public PeopleVM Method1GetPeopleV1()
        {
            PeopleVM people = new PeopleVM();

            try
            {
                using (var client = new HttpClient())
                {
                    string GetRequestUri = String.Format("{0}/api/people/", baseUri);
                    client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/vnd.meijer.cart.cart-v1.0+json"));
                    var result = client.GetAsync(GetRequestUri).Result;
                    if (result.IsSuccessStatusCode)
                    {
                        string resultContent = result.Content.ReadAsStringAsync().Result;
                        people = JsonConvert.DeserializeObject <PeopleVM>(resultContent);
                    }
                    else
                    {
                        throw new Exception(String.Format("Error Calling /api/people", result.ReasonPhrase));
                    }
                }
            }
            catch (Exception ex)
            {
            }
            return(people);
        }
예제 #3
0
        public PeopleView()
        {
            InitializeComponent();
            vm4 = new PeopleVM();
            this.DataContext = vm4;

            vm4.GetData();
        }
 public void FillMongoAndElasticSearch(PeopleVM people)
 {
     using (var client = new PeopleWebClient())
     {
         var dataString = JsonConvert.SerializeObject(people);
         client.Headers.Add(HttpRequestHeader.ContentType, "application/json");
         client.UploadString(new Uri("http://localhost:49987/odata4/People"), "POST", dataString);
     }
 }
예제 #5
0
 public PeopleVM Create(PeopleVM person)
 {
     return(new PeopleVM()
     {
         Id = person.Id,
         Url = _UrlHelper.Link("GetPersonByIdV1", new { id = person.Id }),
         FirstName = person.FirstName,
         LastName = person.LastName
     });
 }
예제 #6
0
        public IActionResult Put([FromBody] PeopleVM peopleVM)
        {
            if (!ModelState.IsValid)
            {
                NotifyModelStateErrors();
                return(Response(peopleVM));
            }

            _peopleService.Update(peopleVM);

            return(Response(peopleVM));
        }
        public IPeople MapPeopleVmToDto(PeopleVM peopleVm)
        {
            IPeople peopleDto = new Application.DTO.People.People()
            {
                EmailID   = peopleVm.EmailID,
                FirstName = peopleVm.FirstName,
                MidName   = peopleVm.MidName,
                LastName  = peopleVm.LastName,
                FullName  = peopleVm.FullName
            };


            return(peopleDto);
        }
예제 #8
0
        public IActionResult Create(PeopleVM request)
        {
            if (!ModelState.IsValid)
            {
                return(View(request));
            }
            peopleService.Register(request);

            if (IsValidOperation())
            {
                ViewBag.Sucesso = "People Registered!";
            }

            return(View(request));
        }
예제 #9
0
        public ActionResult CreatePeople(PeopleVM people)
        {
            int peopleID = _peopleService.CreatePeople(new PeoplesControllerHelper().MapPeopleVmToDto(people));


            // Create Hang Fire Job

            people.PeopleID = peopleID;

            BackgroundJob.Enqueue <PeoplesControllerHelper> (x => x.FillMongoAndElasticSearch(people));



            return(Json(people));
        }
예제 #10
0
        public IActionResult Edit(PeopleVM request)
        {
            if (!ModelState.IsValid)
            {
                return(View(request));
            }

            peopleService.Update(request);

            if (IsValidOperation())
            {
                ViewBag.Sucesso = "People Updated!";
            }

            return(View(request));
        }
예제 #11
0
        public IHttpActionResult Post([FromBody] PeopleVM people)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest());
            }

            try
            {
                _peopleService.CreatePeopleDocumentInMongo(new PeopleControllerHelper().MapPeopleVmToDto(people));


                _peopleService.CreatePeopleDocumentInElastic(new PeopleControllerHelper().MapPeopleVmToDto(people));
            }

            catch (Exception ex)
            {
                return(BadRequest());
            }

            //var message = Request.CreateResponse(HttpStatusCode.Created, people);

            return(Ok());
        }
예제 #12
0
        public void AddPeople(PeopleVM vm)
        {
            var repo = new PeopleRepository(_connection);

            repo.AddPeople(vm.AgeRange, vm.Amount);
        }
예제 #13
0
        public void Register(PeopleVM peopleVM)
        {
            var registerCommand = mapper.Map <RegisterNewPeopleCommand>(peopleVM);

            bus.SendCommand(registerCommand);
        }
예제 #14
0
        public bool Save(PeopleVM people)
        {
            var result = _repository.Add(_mapper.Map <People>(people));

            return(result > 0);
        }
예제 #15
0
 public ActionResult Post([FromBody] PeopleVM people)
 {
     return(Created("", _service.Save(people)));
 }