Ejemplo n.º 1
0
        // GET: Person/Details/5
        public ActionResult Details(long id)
        {
            WebPersonService.PersonDto personDto = null;
            try
            {
                var url = _iconfiguration.GetValue <string>("WebServices:Person:WebPersonService");
                WebPersonService.WebPersonServiceSoapClient soapClient = new WebPersonService.WebPersonServiceSoapClient(new BasicHttpBinding(BasicHttpSecurityMode.None), new EndpointAddress(url));
                personDto = soapClient.Get(id);
            }
            catch (System.Net.Http.HttpRequestException ex)
            {
                _logger.LogCritical(ex.Message);
                _logger.LogCritical(ex.StackTrace);
            }
            catch (Exception ex)
            {
                _logger.LogCritical(ex.Message);
                _logger.LogCritical(ex.StackTrace);
            }

            PersonModel userModel = new PersonModel
            {
                PersonId = personDto.PersonId,
                BirthDay = personDto.BirthDay,
                Deleted  = personDto.Deleted,
                LastName = personDto.LastName,
                Name     = personDto.Name,
                Gender   = new GenderModel()
                {
                    GenderId = personDto.Gender.GenderId, Name = personDto.Gender.Name
                }
            };

            return(View(userModel));
        }
Ejemplo n.º 2
0
        // GET: Person/Edit/5
        public ActionResult Edit(long id)
        {
            PersonController personController = new PersonController(logger, _iconfiguration);

            WebPersonService.PersonDto personDto = null;
            try
            {
                ViewBag.ListPersonType = new Microsoft.AspNetCore.Mvc.Rendering.SelectList(
                    (
                        from person in personController.PersonListModel
                        select new SelectListItem
                {
                    Text = person.Name,
                    Value = person.PersonId.ToString()
                }
                    )
                    , "Value", "Text");

                var url = _iconfiguration.GetValue <string>("WebServices:Person:WebPersonService");
                WebPersonService.WebPersonServiceSoapClient soapClient = new WebPersonService.WebPersonServiceSoapClient(new BasicHttpBinding(BasicHttpSecurityMode.None), new EndpointAddress(url));
                personDto = soapClient.Get(id);
            }
            catch (System.Net.Http.HttpRequestException ex)
            {
                _logger.LogCritical(ex.Message);
                _logger.LogCritical(ex.StackTrace);
            }
            catch (Exception ex)
            {
                _logger.LogCritical(ex.Message);
                _logger.LogCritical(ex.StackTrace);
            }

            PersonModel userModel = new PersonModel
            {
                PersonId = personDto.PersonId,
                BirthDay = personDto.BirthDay,
                Deleted  = personDto.Deleted,
                LastName = personDto.LastName,
                Name     = personDto.Name,
                Gender   = new GenderModel()
                {
                    GenderId = personDto.Gender.GenderId, Name = personDto.Gender.Name
                }
            };

            return(View(userModel));
        }