public async Task <ActionResult <Response> > GetPersonAsync(string firstName)
        {
            PersonServiceClient personClient = new PersonServiceClient();
            Response            response     = await personClient.GetPersonAsync(new Request { FirstName = firstName });

            return(Ok(new { response.ResponseMessage, response.PersonList }));
        }
Ejemplo n.º 2
0
        public async Task GetPerson_ThrowsException()
        {
            PersonRepositoryMock.Setup(x => x.GetById(It.IsAny <int>()))
            .Throws(new InvalidOperationException());

            var result = await PersonServiceClient.GetPerson("1");
        }
        public Models.Customer Login(string Email, string Password)
        {
            using (PersonServiceClient proxy = new PersonServiceClient())
            {
                Customer        customer = null;
                Models.Customer Cc       = new Models.Customer();
                if (Email != null || Password != null)
                {
                    try
                    {
                        customer = proxy.LoginCustomer(Email, Password);
                    }
                    catch (System.NullReferenceException e)
                    {
                        Debug.WriteLine(e.Message);
                        Cc = null;
                    }

                    if (customer != null)
                    {
                        Cc.Email      = customer.Email;
                        Cc.Password   = customer.Password;
                        Cc.CustomerId = customer.CustomerId;
                        Cc.FName      = customer.FName;
                        Cc.LName      = customer.LName;
                        Cc.PhoneNo    = customer.PhoneNo;
                    }
                }
                return(Cc);
            }
        }
Ejemplo n.º 4
0
        static void Main(string[] args)
        {
            using (var wcfSoapClient = new PersonServiceClient())
            {
                string data = wcfSoapClient.GetData("1973");
                Console.WriteLine(data);

                CompositeType composite = new CompositeType
                {
                    BoolValue   = true,
                    StringValue = "Helo WCF Service"
                };

                composite = wcfSoapClient.GetDataUsingDataContract(composite);
                Console.WriteLine("composite: " + composite.StringValue);


                var persons = wcfSoapClient.GetAllPersons();


                foreach (var person in persons)
                {
                    Console.WriteLine(person.name);
                }
            }

            Console.ReadKey();
        }
Ejemplo n.º 5
0
        public bool InsertReservation(Models.Reservation r)
        {
            using (PersonServiceClient proxy = new PersonServiceClient())
            {
                Reservation res = new Reservation();
                res.ReservationId = r.ReservationId;
                res.MovieId       = r.MovieId;
                res.Date          = r.Date;
                res.CustomerId    = r.CustomerId;
                res.Seats         = new List <Seat>();

                foreach (Models.Seat s in r.Seats)
                {
                    Seat seat = new Seat();
                    seat.HallId = s.HallId;
                    seat.Number = s.Number;
                    seat.ResId  = s.ResId;
                    seat.Row    = s.Row;
                    seat.SeatId = s.SeatId;
                    res.Seats.Add(seat);
                }

                return(proxy.InsertReservation(res));
            }
        }
 private void AbstractFetchButton_Click(object sender, RoutedEventArgs e)
 {
     var proxy = new PersonServiceClient();
     IEnumerable<Person> people = proxy.GetPeople();
     foreach (var person in people)
         PersonListBox.Items.Add(person);
 }
 public ActionResult Index(PersonAddressModel model)
 {
     var client = new PersonServiceClient();
     var persons = client.GetPersons(1, model.City, model.Province, model.Country, model.Name).ToList();
     model.Items = persons;
     return View(model);
 }
        public void TestGetPersonById()
        {
            PersonServiceClient client = new PersonServiceClient();

            var person = client.GetPersonById(5, new PersonIncludes { Phones = true, Addressses = true, Accounts = true });

            client.Close();
        }
Ejemplo n.º 9
0
        private void button3_Click(object sender, EventArgs e)
        {
            button3.Enabled = false;
            PersonServiceClient client = new PersonServiceClient();

            client.AddCustomer("1", "5", 1);
            button3.Enabled = true;
        }
        /// <summary>
        /// Create and initialize a New Sale Window.
        /// </summary>
        /// <param name="_people">The collection of people to choose from.</param>
        public NewSaleWindow()
        {
            PSClient = new PersonServiceClient();

            InitializeComponent();

            Initialize_ComboBoxes();
        }
Ejemplo n.º 11
0
 public bool Login(string username, string password)
 {
     using (PersonServiceClient proxy = new PersonServiceClient())
     {
         bool verified = proxy.LogOn(username, password);
         return(verified);
     }
 }
        public ActionResult Index(PersonAddressModel model)
        {
            var client  = new PersonServiceClient();
            var persons = client.GetPersons(2, model.City, model.Province, model.Country, model.Name).ToList();

            model.Items = persons;
            return(View(model));
        }
Ejemplo n.º 13
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!IsCallback)
     {
         serviceClient = new PersonServiceClient();
         persons       = serviceClient.GetPersons();
         personTypes   = serviceClient.GetPersonTypes();
     }
 }
Ejemplo n.º 14
0
        /// <summary>
        /// Static method to obtain instance of the PersonService
        /// </summary>
        /// <param name="binding">The binding that defines the how the. Currently 2 pre-defined bindings are provided
        /// UsernameTokenOverSslBinding and UsernameTokenBinding. The binding used must match the OWSM policy defined on the service</param>
        /// <param name="endpointAddress">The URL of the endpoint that hosts the service</param>
        /// <param name="credentials">The credentials to be used to invoke the service</param>
        /// <returns>Instance of the PersonService client</returns>
        public static PersonServiceClient GetPersonServiceClient(System.ServiceModel.Channels.Binding binding, EndpointAddress endpointAddress, NetworkCredential credentials)
        {
            PersonServiceClient client = new PersonServiceClient(binding, endpointAddress);

            client.ClientCredentials.UserName.UserName = credentials.UserName;
            client.ClientCredentials.UserName.Password = credentials.Password;
            client.Endpoint.Behaviors.Add(new EmptyElementBehavior());
            return(client);
        }
Ejemplo n.º 15
0
        public void AssertThatTheServiceCanRun()
        {
            PersonServiceClient client = new PersonServiceClient();

            client.Open();
            Assert.IsNotNull(client);
            Assert.IsTrue(client.State == CommunicationState.Opened);
            client.Close();
            Assert.IsTrue(client.State == CommunicationState.Closed);
        }
Ejemplo n.º 16
0
        private void ClickMeButton_Click(object sender, RoutedEventArgs e)
        {
            var proxy  = new PersonServiceClient();
            var people = proxy.GetPeople();

            foreach (var person in people)
            {
                PersonListBox.Items.Add(person);
            }
        }
Ejemplo n.º 17
0
        public async Task GetPerson_ReturnsCorrectResult()
        {
            PersonRepositoryMock.Setup(x => x.GetById(It.IsAny <int>()))
            .Returns(_person);

            var response = await PersonServiceClient.GetPerson("1");

            Assert.AreEqual(HttpStatusCode.OK, response.StatusCode);
            Assert.AreEqual("Mocked LN1", response.Result.LastName);
        }
Ejemplo n.º 18
0
        private void AbstractFetchButton_Click(object sender, RoutedEventArgs e)
        {
            var proxy = new PersonServiceClient();
            IEnumerable <Person> people = proxy.GetPeople();

            foreach (var person in people)
            {
                PersonListBox.Items.Add(person);
            }
        }
        private PersonServiceClient GetService()
        {
            var binding       = GetBinding();
            var serviceClient = new PersonServiceClient(binding, new EndpointAddress(_configuration.ServiceUrl));

            serviceClient.ClientCredentials.Windows.ClientCredential = GetCredential();
            (serviceClient as ICommunicationObject).Faulted         += InnerChannel_Faulted;

            return(serviceClient);
        }
Ejemplo n.º 20
0
 static void Main()
 {
     using (var client = new PersonServiceClient())
     {
         RunAllPersons(client);
         RunAllPersonsFromJapan(client);
         RunAllPersonsOfAge100(client);
         RunAllMalePersons(client);
         RunAllLivingPersons(client);
     }
 }
Ejemplo n.º 21
0
 static void Main()
 {
     using (var client = new PersonServiceClient())
     {
         RunAllPersons(client);
         RunAllPersonsFromJapan(client);
         RunAllPersonsOfAge100(client);
         RunAllMalePersons(client);
         RunAllLivingPersons(client);
     }
 }
        public void TestGetPersonById()
        {
            var client = new PersonServiceClient();

            var person = client.GetPersonById(5, new PersonIncludes {
                Phones = true, Addressses = true, Accounts = true
            });

            client.Close();

            Assert.IsNotNull(person);
        }
Ejemplo n.º 23
0
 public void AssertThatCanAddANewPerson()
 {
     using (PersonServiceClient client = new PersonServiceClient())
     {
         client.Open();
         Person person = new Person {
             FirstName = "Raffaele", LastName = "Garofalo"
         };
         client.AddPerson(person);
         bool result = client.HasPerson(person);
         Assert.IsTrue(result);
     }
 }
Ejemplo n.º 24
0
        public async Task GetPersons()
        {
            PersonRepositoryMock.Setup(x => x.GetAll())
            .Returns(new List <Person> {
                _person
            });

            var response = await PersonServiceClient.GetPersons();

            Assert.AreEqual(HttpStatusCode.OK, response.StatusCode);
            Assert.AreEqual(1, response.Result.Count);
            Assert.AreEqual("Mocked LN1", response.Result[0].LastName);
        }
Ejemplo n.º 25
0
 private static async Task Subscribe(PersonServiceClient client)
 {
     using (var call = client.Subscribe(new Empty()))
     {
         while (await call.ResponseStream.MoveNext())
         {
             var person = call.ResponseStream.Current;
             Console.WriteLine("Got a new person:");
             Console.WriteLine(person);
         }
     }
     //Console.WriteLine("Persons: " + reply.);
 }
Ejemplo n.º 26
0
        static void Main()
        {
            using (var client = new PersonServiceClient())
            {
                var consultantList = client.GetConsultants();

                foreach (var consultant in consultantList)
                {
                    Console.WriteLine($"{consultant.FirstName} {consultant.LastName}");
                }

                Console.ReadLine();
            }
        }
Ejemplo n.º 27
0
        public BaseTest()
        {
            PersonRepositoryMock = new Mock <IPersonRepository>();

            var server = new TestServer(new WebHostBuilder()
                                        .UseStartup <StartupMock>()
                                        .ConfigureServices(services =>
            {
                services.AddSingleton(PersonRepositoryMock.Object);
            }));

            var httpClient = server.CreateClient();

            PersonServiceClient = new PersonServiceClient(httpClient);
        }
Ejemplo n.º 28
0
        public async Task GetRounds()
        {
            string gamekey = "3453532";

            PersonRepositoryMock.Setup(x => x.GetAll(1))
            .Returns(new List <Round> {
                _round
            });

            var response = await PersonServiceClient.GetPersons();

            Assert.AreEqual(HttpStatusCode.OK, response.StatusCode);
            Assert.AreEqual(1, response.Result.Count);
            Assert.AreEqual("Mocked FN1", response.Result[0].Name);
        }
Ejemplo n.º 29
0
        static void Main(string[] args)
        {
            //var channel = GrpcChannel.ForAddress("https://localhost:50051");
            var channel = new Channel("127.0.0.1", 50051, ChannelCredentials.Insecure);
            var client  = new PersonServiceClient(channel);

            ListPersons(client).ConfigureAwait(false).GetAwaiter().GetResult();
            UpdatePerson(client).ConfigureAwait(false).GetAwaiter().GetResult();
            Subscribe(client).ConfigureAwait(false).GetAwaiter().GetResult();

            //await ServerStreamingCallExample(client);

            Console.WriteLine("Shutting down");
            Console.WriteLine("Press any key to exit...");
            Console.ReadKey();
        }
Ejemplo n.º 30
0
        private void button1_Click(object sender, EventArgs e)
        {
            button1.Enabled = false;
            PersonServiceClient client    = new PersonServiceClient();
            PersonDTO           personDto = client.GetPerson(textBox1.Text);

            if (personDto != null)
            {
                button1.Text = personDto.Firstname;
            }
            else
            {
                button1.Text = "not found";
            }
            button1.Enabled = true;
        }
Ejemplo n.º 31
0
 public Model.Movie GetMovie(int id)
 {
     using (PersonServiceClient proxy = new PersonServiceClient())
     {
         Movie       m     = proxy.GetMovie(id);
         Model.Movie movie = new Model.Movie();
         movie.MovieId      = m.MovieId;
         movie.MovieLength  = m.MovieLength;
         movie.PremiereDate = m.PremiereDate;
         movie.Resume       = m.Resume;
         movie.Title        = m.Title;
         movie.ImagePath    = m.ImagePath;
         movie.Genre        = m.Genre;
         return(movie);
     }
 }
        public ActionResult Index(string id)
        {
            var model = new PersonAddressModel();
            if (!string.IsNullOrEmpty(id))
            {
                var personID = int.Parse(id);
                if (personID > 0)
                {
                    var client = new PersonServiceClient();
                    var addresses = client.GetAddressesByPersonID(personID).ToList();
                    model.Items = addresses;
                }
            }

            return View(model);
        }
        public ActionResult Index(string id)
        {
            var model = new PersonAddressModel();

            if (!string.IsNullOrEmpty(id))
            {
                var personID = int.Parse(id);
                if (personID > 0)
                {
                    var client    = new PersonServiceClient();
                    var addresses = client.GetAddressesByPersonID(personID).ToList();
                    model.Items = addresses;
                }
            }

            return(View(model));
        }
Ejemplo n.º 34
0
        private void ConfigureContainer()
        {
            container = new UnityContainer();

            // Instantiate and register the Person Service
            var personService = new PersonServiceClient();

            container.RegisterInstance <IPersonService>(personService);

            // Instantiate and register our (fake) model
            var order = new CatalogOrder()
            {
                SelectedPeople = new ObservableCollection <Person>()
            };

            container.RegisterInstance <CatalogOrder>("CurrentOrder", order);
        }
        public void TestPersonDocumentSearch()
        {
            var client = new PersonServiceClient();

            var searchCriteria = new PersonDocument();
            searchCriteria.State = "NY";

            var pageOfListPersonDocuments = client.SearchPersons(1, 10, "lastname", SortDirection.Ascending, searchCriteria);
            client.Close();

            // Verify that only 10 records or less are returned
            Assert.IsTrue(pageOfListPersonDocuments.Data.Count <= 10);

            // Verify that only NY state record are returned
            foreach (PersonDocument personDoc in pageOfListPersonDocuments.Data)
                Assert.AreEqual(personDoc.State, "NY");
        }
Ejemplo n.º 36
0
        public Person GetPerson(string NIN)
        {
            PersonServiceClient client = new PersonServiceClient();

            client.ClientCredentials.UserName.UserName = "******";
            client.ClientCredentials.UserName.Password = "******";

            LookupParameters lookupParameter = new LookupParameters();

            lookupParameter.NIN = NIN;

            var person = client.GetPerson(lookupParameter);

            client.Close();

            return(person);
        }
        public void TestPersonDocumentSearch()
        {
            PersonServiceClient client = new PersonServiceClient();

            var searchCriteria = new Dictionary<PersonSearchColumn, string>();
            searchCriteria.Add(PersonSearchColumn.State, "NY");

            var pageOfListPersonDocuments = client.SearchPersons(1, PersonSearchColumn.LastName, SortDirection.Ascending, 10, searchCriteria);

            // Verify that only 10 records or less are returned
            Assert.IsTrue(pageOfListPersonDocuments.Data.Count <= 10);

            // Verify that only NY state record are returned
            foreach (PersonDocument personDoc in pageOfListPersonDocuments.Data)
                Assert.AreEqual(personDoc.State, "NY");

            client.Close();
        }
Ejemplo n.º 38
0
 public List <Model.Hall> FindHalls(int mId)
 {
     using (PersonServiceClient proxy = new PersonServiceClient())
     {
         List <Hall>       halls = proxy.FindHalls(mId);
         List <Model.Hall> mH    = new List <Model.Hall>();
         foreach (Hall tempH in halls)
         {
             Model.Hall h = new Model.Hall();
             h.HallId   = tempH.HallId;
             h.MovieId  = tempH.MovieId;
             h.ShowDate = tempH.ShowDate;
             h.ShowTime = tempH.ShowTime;
             mH.Add(h);
         }
         return(mH);
     }
 }
Ejemplo n.º 39
0
        static void Main(string[] args)
        {
            PersonServiceClient client=new PersonServiceClient();
            Person nullPerson = client.GetPerson(0);
            Person person = client.GetPerson(1);

            Console.WriteLine(nullPerson == null ? "Person object is null" : nullPerson.Name);

            Console.WriteLine(person.Name);

            try
            {
                Console.WriteLine(nullPerson.Name);
            }
            catch (Exception exception)
            {
                Console.WriteLine("Exception"+exception.Message);
            }

            Console.ReadLine();
        }
 public PersonServiceRepository()
 {
     proxy = new PersonServiceClient();
 }
 /// <summary>
 /// Static method to obtain instance of the PersonService
 /// </summary>
 /// <param name="binding">The binding that defines the how the. Currently 2 pre-defined bindings are provided 
 /// UsernameTokenOverSslBinding and UsernameTokenBinding. The binding used must match the OWSM policy defined on the service</param>
 /// <param name="endpointAddress">The URL of the endpoint that hosts the service</param>
 /// <param name="credentials">The credentials to be used to invoke the service</param>
 /// <returns>Instance of the PersonService client</returns>
 public static PersonServiceClient GetPersonServiceClient(System.ServiceModel.Channels.Binding binding, EndpointAddress endpointAddress, NetworkCredential credentials)
 {
     PersonServiceClient client = new PersonServiceClient(binding, endpointAddress);
     client.ClientCredentials.UserName.UserName = credentials.UserName;
     client.ClientCredentials.UserName.Password = credentials.Password;
     client.Endpoint.Behaviors.Add(new EmptyElementBehavior());
     return client;
 }
Ejemplo n.º 42
0
 static void Main(string[] args)
 {
     PersonServiceClient client = new PersonServiceClient();
     Console.WriteLine(client.GetPersonById(1));
     Console.ReadLine();
 }
 public ServiceRepository()
 {
     ServiceProxy = new PersonServiceClient();
 }
Ejemplo n.º 44
0
        /// <summary>
        /// Initialize instance members, window components, and then populate components with data from instance members.
        /// </summary>
        public MainWindow()
        {
            PSClient = new PersonServiceClient();
            Audit += AuditListener;

            // Make sure there's a connection to the server first. If there's not, provide the information to the Audit.
            try
            {
                PSClient.Ping("Pong!");
            }
            catch (Exception e)
            {
                Audit(this, new ClientAuditArgs("Received", "Ping", "Nothing"));
                this.Close();
            }

            InitializeComponent();

            DataContext = this;

            // Starts with Employee selected
            PersonTypeChooser.SelectedIndex = 0;
        }