// 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)); }
// 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)); }
public ActionResult Create(PersonModel personModel) { try { var url = _iconfiguration.GetValue <string>("WebServices:Person:WebPersonService"); var urlGender = _iconfiguration.GetValue <string>("WebServices:Gender:WebGenderService"); WebPersonService.WebPersonServiceSoapClient soapClient = new WebPersonService.WebPersonServiceSoapClient(new BasicHttpBinding(BasicHttpSecurityMode.None), new EndpointAddress(url)); WebGenderService.WebGenderServiceSoapClient soapClientRole = new WebGenderService.WebGenderServiceSoapClient(new BasicHttpBinding(BasicHttpSecurityMode.None), new EndpointAddress(urlGender)); // TODO: Add insert logic here //WebGenderService.GenderDto gender = soapClientRole.GetId(1); WebPersonService.PersonDto person = new WebPersonService.PersonDto() { PersonId = personModel.PersonId, BirthDay = personModel.BirthDay, Deleted = personModel.Deleted, LastName = personModel.LastName, Name = personModel.Name, Gender = new WebPersonService.GenderDto() { GenderId = personModel.Gender.GenderId, Name = personModel.Gender.Name } }; soapClient.Insert(person); return(RedirectToAction(nameof(Index))); } catch (System.Net.Http.HttpRequestException ex) { _logger.LogCritical(ex.Message); _logger.LogCritical(ex.StackTrace); return(View()); } catch (Exception ex) { _logger.LogCritical(ex.Message); _logger.LogCritical(ex.StackTrace); return(View()); } }
public ActionResult Create(ContactModel contactModel) { try { var url = _iconfiguration.GetValue <string>("WebServices:Contact:WebContactService"); var urlPerson = _iconfiguration.GetValue <string>("WebServices:Person:WebPersonService"); WebContactServices.WebContactServicesSoapClient soapClient = new WebContactServices.WebContactServicesSoapClient(new BasicHttpBinding(BasicHttpSecurityMode.None), new EndpointAddress(url)); WebPersonService.WebPersonServiceSoapClient soapClientPerson = new WebPersonService.WebPersonServiceSoapClient(new BasicHttpBinding(BasicHttpSecurityMode.None), new EndpointAddress(urlPerson)); // TODO: Add insert logic here //WebPersonService.PersonDto person = soapClientPerson.GetId(1); WebContactServices.ContactDto contact = new WebContactServices.ContactDto() { ContactId = contactModel.ContactId, Description = contactModel.Description, Data = contactModel.Data, Deleted = contactModel.Deleted, Person = new WebContactServices.PersonDto() { PersonId = 1, Name = "prueba", LastName = "prueba", BirthDay = DateTime.Now, Deleted = false, Gender = new WebContactServices.GenderDto() { GenderId = 1, Name = "Masculino" }, User = new WebContactServices.UserDto() } }; soapClient.Insert(contact); return(RedirectToAction(nameof(Index))); } catch (System.Net.Http.HttpRequestException ex) { _logger.LogCritical(ex.Message); _logger.LogCritical(ex.StackTrace); return(View()); } catch (Exception ex) { _logger.LogCritical(ex.Message); _logger.LogCritical(ex.StackTrace); return(View()); } }