Exemplo n.º 1
0
        public void Client_Existent()
        {
            RepositoryMock.Setup(x => x.Add(client));
            RepositoryMock.Setup(x => x.GetByEmail(client.Email.ToString())).Returns(client);

            serviceClient.Add(client);
            var list = serviceClient.GetErrors();

            Assert.AreEqual(1, list.Count);
        }
Exemplo n.º 2
0
        public ActionResult Create(Client c)
        {
            try
            {
                Client ca = new Client
                {
                    FirstName           = c.FirstName,
                    LastName            = c.LastName,
                    Category            = c.Category,
                    Type                = c.Type,
                    Addresse            = c.Addresse,
                    OrganizationalChart = c.OrganizationalChart,
                    Logo                = c.Logo,
                    NbProjAf            = c.NbProjAf,
                    NbResInServ         = c.NbResInServ,
                    Email               = c.Email
                };
                sc.Add(ca);
                sc.Commit();

                return(RedirectToAction("Index"));
            }
            catch
            {
                return(View());
            }
        }
        public ActionResult Index()
        {
            var client = new ServiceClient();
            client.Add(new Company {Id = 5, Name = "ABC Company", Address = "1234 Main Street"});

            return View();
        }
Exemplo n.º 4
0
        static void Main(string[] args)
        {
            ServiceClient client = new ServiceClient();

            // Call the Add service operation.
            ComplexNumber value1 = new ComplexNumber();

            value1.Real      = 1;
            value1.Imaginary = 2;
            ComplexNumber value2 = new ComplexNumber();

            value2.Real      = 3;
            value2.Imaginary = 4;
            ComplexNumber result = client.Add(value1, value2);

            Console.WriteLine("Add({0} + {1}i, {2} + {3}i) = {4} + {5}i",
                              value1.Real, value1.Imaginary, value2.Real, value2.Imaginary,
                              result.Real, result.Imaginary);

            //Step 3: Closing the client gracefully closes the connection and cleans up resources.
            client.Close();

            Console.WriteLine();
            Console.WriteLine("Press <ENTER> to terminate client.");
            Console.ReadLine();
        }
        // GET: Calculate
        public ActionResult Index(string Value1, string Value2, string submit)
        {
            int           a = Convert.ToInt32(Value1);
            int           b = Convert.ToInt32(Value2);
            ServiceClient client;

            switch (submit)
            {
            case "Add":
                client         = new ServiceClient("BasicHttpBinding_IService");
                ViewBag.Output = "Result: " + client.Add(a, b).ToString();
                break;

            case "Subract":
                client         = new ServiceClient("BasicHttpBinding_IService");
                ViewBag.Output = "Result: " + client.Subract(a, b).ToString();;
                break;

            case "Multiply":
                client         = new ServiceClient("BasicHttpBinding_IService");
                ViewBag.Output = "Result: " + client.Multiply(a, b).ToString();;
                break;

            case "Divide":
                client         = new ServiceClient("BasicHttpBinding_IService");
                ViewBag.Output = "Result: " + client.Divide(a, b).ToString();;
                break;
            }
            return(View());
        }
Exemplo n.º 6
0
        static void Test1()
        {
            var client = new ServiceClient();
            for (int i = 0; i < 3; i++) {

                var i1 = i;
                Task.Factory.StartNew(() => {
                    Console.WriteLine(string.Format("-------------开始-------------{0}-{1}----------------------------", i1, DateTime.Now));
                    //using () {
                        double value1 = 100.00D;
                        double value2 = 15.99D;
                        double result = client.Add(value1, value2);
                        Console.WriteLine(string.Format("--------------结束------------{0}-{1}-----{2}-----------------------", i1, DateTime.Now, result));
                        //client.Close();
                    //}

                });

            }
            Thread.Sleep(9000);
            using (var client1 = new Online.ClientTest.ServiceReference2.Service1Client()) {
                double value1 = 100.00D;
                double value2 = 15.99D;
                Console.WriteLine(string.Format("-------------开始01-------------{0}-{1}----------------------------", "1111", DateTime.Now));
                double result = client1.Subtract(value1, value2);
                Console.WriteLine(string.Format("--------------结束01------------{0}-{1}-----{2}-----------------------", result, DateTime.Now, result));
                client.Close();
            }
            //for (int i = 0; i < 100; i++) {
            //    var i1 = i;
            //    Task.Factory.StartNew(() => {
            //        Console.WriteLine(string.Format("-------------开始-------------{0}-{1}----------------------------", i1, DateTime.Now));
            //        using (var client = new OauthClient()) {
            //            double value1 = 100.00D;
            //            double value2 = 15.99D;
            //            var result = client.Code("2345");
            //            Console.WriteLine(string.Format("--------------结束------------{0}-{1}-----{2}-----------------------", i1, DateTime.Now, result));
            //        }

            //    });

            //}

            Console.WriteLine("Press <ENTER> to terminate client.");
            Console.ReadLine();
            //using (var client = new ServiceClient()) {
            //    double value1 = 100.00D;
            //    double value2 = 15.99D;
            //    double result = client.Add(value1, value2);
            //    Console.WriteLine("Add({0},{1}) = {2}", value1, value2, result);
            //    Console.WriteLine("Press <ENTER> to terminate client.");
            //    Console.ReadLine();
            //}
        }
Exemplo n.º 7
0
        protected void btnGuardar_Click(object sender, EventArgs e)
        {
            string   name      = txtNombre.Value;
            string   lastName  = txtApellido.Value;
            string   dni       = txtDni.Value;
            string   address   = txtDomicilio.Value;
            DateTime birthdate = Convert.ToDateTime(txtFecha.Value);

            ListClient.Add(name, lastName, dni, address, birthdate);
            txtNombre.Value    = "";
            txtApellido.Value  = "";
            txtDni.Value       = "";
            txtDomicilio.Value = "";
            txtFecha.Value     = "";
        }
        static void Main(string[] args)
        {
            ServiceClient client = new ServiceClient();

              // Call the Add service operation.
              ComplexNumber value1 = new ComplexNumber();
              value1.Real = 1;
              value1.Imaginary = 2;
              ComplexNumber value2 = new ComplexNumber();
              value2.Real = 3;
              value2.Imaginary = 4;
              ComplexNumber result = client.Add(value1, value2);
              Console.WriteLine("Add({0} + {1}i, {2} + {3}i) = {4} + {5}i",
            value1.Real, value1.Imaginary, value2.Real, value2.Imaginary,
            result.Real, result.Imaginary);

              //Step 3: Closing the client gracefully closes the connection and cleans up resources.
              client.Close();

              Console.WriteLine();
              Console.WriteLine("Press <ENTER> to terminate client.");
              Console.ReadLine();
        }
Exemplo n.º 9
0
 public ActionResult Add(Member member)
 {
     _serviceClient.Add(member);
     return(RedirectToAction("Index", "CRUD"));
 }
Exemplo n.º 10
0
        static void Test2()
        {
            //IService client = null;
            // Create a client
            //CalculatorClient client = new CalculatorClient();
            //var client = WcfServiceClientFactory.CreateClient();
            //var client = ServiceProxy.GetTcpService<IService>();
            //var client = ServiceProxy.GetHttpService<IService>();

            //for (int i = 0; i < 1; i++) {
            //    client = ServiceProxy.GetHttpService<IService>();
            //    var items = client.Get(Consts.OrderServiceTypeName).Select(p => p as TestModel).ToList();
            //    foreach (var item in items) {
            //        Console.WriteLine(item.id);
            //    }
            //}
            using (var client =new ServiceClient()) {

                client.Subtract(1, 1);
                Console.WriteLine("Add({0},{1}) = {2}", 1, 1, 2);
                Console.WriteLine("Press <ENTER> to terminate client.");
                Console.ReadLine();
            }
                double value1 = 100.00D;
                double value2 = 15.99D;
                double result1 = ServiceProxy.GetTcpService<IService>().Subtract(value1, value2);
                Console.WriteLine("Add({0},{1}) = {2}", value1, value2, result1);
                Console.WriteLine("Press <ENTER> to terminate client.");
                Console.ReadLine();

            for (int i = 0; i < 100; i++) {
                var i1 = i;
                Task.Factory.StartNew(() => {
                    Console.WriteLine(string.Format("-------------开始-------------{0}-{1}----------------------------", i1, DateTime.Now));
                    var client = ServiceProxy.GetTcpService<IService>();
                    double result = client.Add(1, 1);
                    Console.WriteLine(string.Format("--------------结束------------{0}-{1}-----{2}-----------------------", i1, DateTime.Now, result));
                });
            }
            Console.ReadLine();
            //for (int i = 0; i < 100; i++) {
            //    var i1 = i;
            //    Task.Factory.StartNew(() => {
            //        var client = ServiceProxy.GetHttpService<IService>();
            //        double value1 = 100.00D;
            //        double value2 = 15.99D;
            //        double result = client.Add(value1, value2);

            //        Console.WriteLine(string.Format("--------------------------{0}----------------------------", i1));
            //    });

            //}

            //client = ServiceProxy.GetHttpService<IService>();

            //t = client.Get((new TestModel() { Id = 100, TypeName = "WcfServiceLibrary1.GoodsService" })) as TestModel;
            //Console.WriteLine("AddModel({0}) = {1}", 100, t.Id);

            // Call the Add service operation.
            //double value1 = 100.00D;
            //double value2 = 15.99D;
            //double result = client.Add(value1, value2);
            //Console.WriteLine("Add({0},{1}) = {2}", value1, value2, result);

            // Call the Subtract service operation.
            //value1 = 145.00D;
            //value2 = 76.54D;
            ////result = client.Subtract(value1, value2);
            //Console.WriteLine("Subtract({0},{1}) = {2}", value1, value2, result);

            // Call the Multiply service operation.
            //value1 = 9.00D;
            //value2 = 81.25D;
            ////result = client.Multiply(value1, value2);
            //Console.WriteLine("Multiply({0},{1}) = {2}", value1, value2, result);

            // Call the Divide service operation.
            //value1 = 22.00D;
            //value2 = 7.00D;
            //result = client.Divide(value1, value2);
            //Console.WriteLine("Divide({0},{1}) = {2}", value1, value2, result);

            //Closing the client gracefully closes the connection and cleans up resources

            //Console.WriteLine();
            Console.WriteLine("Press <ENTER> to terminate client.");
            Console.ReadLine();
        }
Exemplo n.º 11
0
        protected void Page_Load(object sender, EventArgs e)
        {
            ServiceClient obj = new ServiceClient();

            Response.Write("result = " + obj.Add(1, 2).ToString());
        }