Exemple #1
0
        // GET: Home
        public ActionResult Index()
        {
            var cars = HelloModel.GetCars();

            ViewBag.HelloWorld = "Hello World";// This is the second way to render "Hello World" on the Index.cshtml view
            return(View(cars));
        }
 private async Task SendHelloObject()
 {
     HelloModel hello = new HelloModel {
         Age = Convert.ToInt32(HelloTextBox.Text), Molly = HelloMollyTextBox.Text
     };
     await Proxy.Invoke("sendHelloObject", hello);
 }
        static void Main(string[] args)
        {
            Console.WriteLine("Starting client  http://localhost:8089");
            var myHubClient = new MyHubClient();

            while (true)
            {
                string key = Console.ReadLine();
                if (key.ToUpper() == "W")
                {
                    if (myHubClient.State == ConnectionState.Connected)
                    {
                        myHubClient.AddMessage("damien client", "hello all");
                    }
                    else
                    {
                        HubClientEvents.Log.Warning("Can't send message, connectionState= " + myHubClient.State);
                    }
                }
                if (key.ToUpper() == "E")
                {
                    if (myHubClient.State == ConnectionState.Connected)
                    {
                        myHubClient.Heartbeat();
                    }
                    else
                    {
                        HubClientEvents.Log.Warning("Can't send message, connectionState= " + myHubClient.State);
                    }
                }
                if (key.ToUpper() == "R")
                {
                    if (myHubClient.State == ConnectionState.Connected)
                    {
                        var hello = new HelloModel {
                            Age = 10, Molly = "clientMessage"
                        };
                        myHubClient.SendHelloObject(hello);
                    }
                    else
                    {
                        HubClientEvents.Log.Warning("Can't send message, connectionState= " + myHubClient.State);
                    }
                }
                if (key.ToUpper() == "T")
                {
                    myHubClient.CloseHub();
                    HubClientEvents.Log.Informational("Closed Hub");
                }
                if (key.ToUpper() == "Z")
                {
                    myHubClient.StartHub();
                    HubClientEvents.Log.Informational("Started the Hub");
                }
                if (key.ToUpper() == "C")
                {
                    break;
                }
            }
        }
Exemple #4
0
        // GET: Home
        public ActionResult Index()
        {
            var cars = HelloModel.GetCars();

            ViewBag.myValue = "Hello MVC";
            return(View(cars));
        }
        // GET: Home
        public ActionResult Index()
        {
            var cars = HelloModel.GetCars();

            ViewBag.DustinCreatedThisValue = "Hello MVC";
            return(View(cars));
        }
Exemple #6
0
        static void Main(string[] args)
        {
            Console.WriteLine("Starting client  http://localhost:8089");

            var hubConnection = new HubConnection("http://localhost:8089/");
            //hubConnection.TraceLevel = TraceLevels.All;
            //hubConnection.TraceWriter = Console.Out;
            IHubProxy myHubProxy = hubConnection.CreateHubProxy("MyHub");

            myHubProxy.On <string, string>("addMessage", (name, message) => Console.Write("Recieved addMessage: " + name + ": " + message + "\n"));
            myHubProxy.On("heartbeat", () => Console.Write("Recieved heartbeat \n"));
            myHubProxy.On <HelloModel>("sendHelloObject", hello => Console.Write("Recieved sendHelloObject {0}, {1} \n", hello.Molly, hello.Age));

            hubConnection.Start().Wait();

            while (true)
            {
                string key = Console.ReadLine();
                if (key.ToUpper() == "W")
                {
                    myHubProxy.Invoke("addMessage", "client message", " sent from console client").ContinueWith(task =>
                    {
                        if (task.IsFaulted)
                        {
                            Console.WriteLine("!!! There was an error opening the connection:{0} \n", task.Exception.GetBaseException());
                        }
                    }).Wait();
                    Console.WriteLine("Client Sending addMessage to server\n");
                }
                if (key.ToUpper() == "E")
                {
                    myHubProxy.Invoke("Heartbeat").ContinueWith(task =>
                    {
                        if (task.IsFaulted)
                        {
                            Console.WriteLine("There was an error opening the connection:{0}", task.Exception.GetBaseException());
                        }
                    }).Wait();
                    Console.WriteLine("client heartbeat sent to server\n");
                }
                if (key.ToUpper() == "R")
                {
                    HelloModel hello = new HelloModel {
                        Age = 10, Molly = "clientMessage"
                    };
                    myHubProxy.Invoke <HelloModel>("SendHelloObject", hello).ContinueWith(task =>
                    {
                        if (task.IsFaulted)
                        {
                            Console.WriteLine("There was an error opening the connection:{0}", task.Exception.GetBaseException());
                        }
                    }).Wait();
                    Console.WriteLine("client sendHelloObject sent to server\n");
                }
                if (key.ToUpper() == "C")
                {
                    break;
                }
            }
        }
Exemple #7
0
        public APIGatewayProxyResponse FunctionHandler(APIGatewayProxyRequest request, ILambdaContext context)
        {
            string name = null;

            //request.QueryStringParameters["abc"]
            if (request.QueryStringParameters != null && request.QueryStringParameters.ContainsKey("name"))
            {
                name = request.QueryStringParameters["name"];
            }

            if (!String.IsNullOrEmpty(name))
            {
                //
                var data = new HelloModel {
                    message = Hello(name)
                };

                APIGatewayProxyResponse respond = new APIGatewayProxyResponse {
                    StatusCode = (int)HttpStatusCode.OK,
                    Headers    = new Dictionary <string, string>
                    {
                        { "Content-Type", "application/json" },
                        { "Access-Control-Allow-Origin", "*" }
                    },
                    Body = JsonConvert.SerializeObject(data)
                };

                return(respond);
            }

            return(new APIGatewayProxyResponse
            {
                StatusCode = (int)HttpStatusCode.NotFound
            });
        }
        public async Task <IActionResult> Hello(string model)
        {
            try
            {
                bool result = await logicUnitOfWork.PublicService.HelloAsync(model);

                HelloModel response = new HelloModel();

                if (result == true)
                {
                    response.code    = ResponseEnum.Success;
                    response.Message = ResponseEnum.Success.ToString();
                    response.Data    = model;
                }

                // ถ้าต้องการลอง catch - Un comment นี้
                //throw new Exception();

                return(Ok(response));
            }
            catch (Exception)
            {
                HelloModel response = new HelloModel()
                {
                    code    = ResponseEnum.Error,
                    Message = ResponseEnum.Error.ToString(),
                    Data    = null
                };

                return(BadRequest(response));
            }
        }
Exemple #9
0
 public ActionResult HelloView(HelloModel hello)
 {
     ModelState.Clear();
     hello.str1 = "Hello";
     hello.str2 = "World";
     return(View("HelloView" /*cshtml*/, hello));
 }
Exemple #10
0
        // GET: Home
        public ActionResult Index()
        {
            var cars = HelloModel.GetCars();

            ViewBag.MainHeadline = "Main Headline";

            return(View(cars));
        }
Exemple #11
0
        // GET: Home
        public ActionResult Index()
        {
            var cars = HelloModel.GetCars();           // to get the cars

            ViewBag.AntoCreateThisValue = "Hello MVC"; // inline

            return(View(cars));
        }
Exemple #12
0
        public IActionResult Index()
        {
            HelloModel model = new HelloModel();

            model.Name = "名無しさん";

            return(View(model));
        }
Exemple #13
0
        public ActionResult Hello()
        {
            var model = new HelloModel {
                A = "Jessica", B = 55
            };

            return(View(model));
        }
Exemple #14
0
        public IActionResult Index()
        {
            HelloModel _model = new HelloModel()
            {
                Message = "Hello, Dima"
            };

            return(View(_model));
        }
        public IActionResult Home()
        {
            var model = new HelloModel {
                Blueprint = _blueprint,
                Exists    = _serviceProvider.GetService <TestInjection>() != null
            };

            return(View(model));
        }
Exemple #16
0
        public IActionResult Index(HelloModel model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            return(View("GreetUser", model));
        }
 public void Recieve_SendHelloObject(HelloModel hello)
 {
     if (RecievedMessageEvent != null)
     {
         RecievedMessageEvent.Invoke(new MyMessage {
             Name = hello.Age.ToString(), Message = hello.Molly
         });
     }
     HubClientEvents.Log.Informational("Received sendHelloObject " + hello.Molly + ", " + hello.Age);
 }
Exemple #18
0
        // PUT api/hello/5
        public void Put(int id, [FromBody] string value)
        {
            var repo  = new HelloWorldRepository();
            var hello = new HelloModel()
            {
                Id = id, Message = value
            };

            repo.UpdateHelloWorld(hello);
        }
Exemple #19
0
 public string Post(HelloModel model)
 {
     try {
         if (model.Name == "The End")
             return string.Format("{0}! That's all folks!", model.Name);
         return string.Format("Hello, {0}!!", model.Name);
     }
     catch (Exception e) {
         return e.Message;
     }
 }
        public IActionResult Index()
        {
            HelloModel _model = new HelloModel()
            {
                HelloMessage = "Hi there!"
            };
            //List<Directory> directories = _context.Directories.Include(x => x.Materials).ToList();
            List <Directory> directories = _dataManager.DirectoryRepository.GetDirectories(true).ToList();

            return(View(directories));// (_model);
        }
        public ActionResult TypedIndex()
        {
            var model = new HelloModel()
            {
                Message = "HElllooo World",
                Date    = DateTime.Now
            };

            //return View("viewName", model);
            return(View(model));
        }
Exemple #22
0
 public void SendHelloObject(HelloModel hello)
 {
     _myHubProxy.Invoke <HelloModel>("SendHelloObject", hello).ContinueWith(task =>
     {
         if (task.IsFaulted)
         {
             HubClientEvents.Log.Error("There was an error opening the connection:" + task.Exception.GetBaseException());
         }
     }).Wait();
     HubClientEvents.Log.Informational("Client sendHelloObject sent to server");
 }
Exemple #23
0
        public ViewResult Hello()
        {
            //ViewData.Add("data1", " Hello World (From controller using ViewData)!");
            //ViewBag.data2 = "Hello World (From controller using ViewBag)!";
            HelloModel model = new HelloModel()
            {
                Data = "Hello World (From controller using Model)!"
            };

            //ViewData.Model = model;
            return(View(model));
        }
Exemple #24
0
        public IActionResult Index()
        {
            HelloModel _model = new HelloModel()
            {
                HelloMessage = "I see you!"
            };
            //  List<Directory> _dirs = _context.Directory.Include(x=>x.Materials).ToList();
            //List<Directory> _dirs = _dirRep.GetAllDirectorys().ToList();
            List <DirectoryViewModel> _dirs = _servicesmanager.Directorys.GetDirectoryesList();

            return(View(_dirs));
        }
        public IActionResult Index()
        {
            HelloModel helloModel = new HelloModel()
            {
                HelloMassage = "Hi man!"
            };
            //List<Directory> dirs = context.Directory.Include(x=>x.Materials).ToList();
            //List<Directory> dirs = dirRep.GetAllDirectorys().ToList();
            //List<Directory> dirs = dataManager.Directorys.GetAllDirectorys(true).ToList();
            List <DirectoryViewModel> dirs = servicesManager.Directorys.GetDirectoryesList();

            return(View(dirs));
        }
        private async void Button_Click_1(object sender, RoutedEventArgs e) {

            IsWorking = true;
            ResponseMessage = string.Empty;
            
            //Load data 
            try {
                // Call the web API and display the result
                
                //the client
                HttpClient client = new HttpClient();
                
                //your model
                var postData = new HelloModel();
                postData.Name = txtName.Text;

                //serialize as JSON
                var content = new StringContent(JsonConvert.SerializeObject(postData));
                content.Headers.ContentType = new MediaTypeHeaderValue("application/json");
                //Post it!

                HttpResponseMessage response = await client.PostAsync(_address, content);
                //get response
                

                if (response.StatusCode == HttpStatusCode.OK)
                {
                    string responseText = await response.Content.ReadAsStringAsync();
                    ResponseMessage = responseText.Trim('"');
                }
                    
                else {
                    ResponseMessage = response.StatusCode.ToString();
                }
                if (ResponseMessage.Contains("The End")) {
                    ThreadPool.RunAsync(operation => {
                        new System.Threading.ManualResetEvent(false).WaitOne(10000);
                        Dispatcher.RunAsync(CoreDispatcherPriority.Normal,
                                            () => IsTheEnd = true);
                    });
                }


            }
            catch (Exception ex) {
                ResponseMessage = "An error occurred: " + ex.Message;
            }
            finally {
                IsWorking = false;
            }
        }
 public IHttpActionResult Post([FromBody] string value)
 {
     try
     {
         HelloModel objHelloModel = new HelloModel()
         {
             Message = value.ToString()
         };
         _objHelloBAL.Save(objHelloModel);
         return(Ok());
     }
     catch (HttpRequestException httpRequestException)
     {
         return(BadRequest("Error: " + httpRequestException.Message));
     }
 }
Exemple #28
0
        public int UpdateHelloWorld(HelloModel hello)
        {
            //using (var conn = new SqlConnection(ConfigurationManager.ConnectionStrings["SqlConnection"].ConnectionString))
            //using (var cmd = new SqlCommand("UpdateHelloWorld", conn))
            //{
            //    cmd.CommandType = CommandType.StoredProcedure;
            //    cmd.CommandTimeout = 3500;
            //    cmd.Parameters.AddWithValue("@Message", hello.Message);
            //    cmd.Parameters.AddWithValue("@Id", hello.Id);

            //    var value = cmd.ExecuteNonQuery();

            //}

            return(1);
        }
        static void Main(string[] args)
        {
            // This will *ONLY* bind to localhost, if you want to bind to all addresses
            // use http://*:8080 to bind to all addresses.
            // See http://msdn.microsoft.com/en-us/library/system.net.httplistener.aspx
            // for more information.
            string url = "http://localhost:8089";

            using (WebApp.Start(url))
            {
                Console.WriteLine("Server running on {0}", url);
                while (true)
                {
                    string key = Console.ReadLine();
                    if (key.ToUpper() == "W")
                    {
                        IHubContext hubContext = GlobalHost.ConnectionManager.GetHubContext <MyHub>();
                        hubContext.Clients.All.addMessage("server", "ServerMessage");
                        Console.WriteLine("Server Sending addMessage\n");
                    }
                    if (key.ToUpper() == "E")
                    {
                        IHubContext hubContext = GlobalHost.ConnectionManager.GetHubContext <MyHub>();
                        hubContext.Clients.All.heartbeat();
                        Console.WriteLine("Server Sending heartbeat\n");
                    }
                    if (key.ToUpper() == "R")
                    {
                        IHubContext hubContext = GlobalHost.ConnectionManager.GetHubContext <MyHub>();

                        var vv = new HelloModel {
                            Age = 37, Molly = "pushed direct from Server "
                        };

                        hubContext.Clients.All.sendHelloObject(vv);
                        Console.WriteLine("Server Sending sendHelloObject\n");
                    }
                    if (key.ToUpper() == "C")
                    {
                        break;
                    }
                }

                Console.ReadLine();
            }
        }
        public IActionResult Index()
        {
            HelloModel _model = new HelloModel()
            {
                HelloMessage = "Kostiantyn"
            };

            //first case about work with context db
            //List<Directory> _dirs = _contex.Directory.Include(d => d.Materials).ToList();

            //second case about work with context db
            //List<Directory> _dirs = _dirRep.GetAllDirectorys().ToList();

            //third case about work with context db
            List <Directory> _dirs = _dataManager.Directorys.GetAllDirectorys(true).ToList();

            return(View(_dirs));
        }
Exemple #31
0
        public IActionResult Index()
        {
            HelloModel _model = new HelloModel()
            {
                HelloMessage = "Aidar!"
            };

            //List<Directory> _dirs = _context.Directory.Include(x=>x.Materials).ToList(); // Get from Database context

            //List<Directory> _dirs = _dirRep.GetAllDirectorys().ToList(); // Get from Repository

            //List<Directory> _dirs = _dataManager.Directorys.GetAllDirectorys(true).ToList(); //Get from DataManager

            List <DirectoryViewModel> _dirs = _servicesmanager.Directorys.GetDirectoryesList();            //Get from DataBase converted


            return(View(_dirs));
        }
Exemple #32
0
        HelloModel IHelloDataAccess.Save(HelloModel obj)
        {
            HelloModel message = new HelloModel();

            if (messages == null)
            {
                message = new HelloModel
                {
                    ID      = 1,
                    Message = obj.Message
                };

                //  messages.Add(message);
                return(message);
            }
            message.ID      = messages.Count + 1;
            message.Message = obj.Message;
            return(message);
        }
        static void Main(string[] args)
        {
            // This will *ONLY* bind to localhost, if you want to bind to all addresses
            // use http://*:8080 to bind to all addresses.
            // See http://msdn.microsoft.com/en-us/library/system.net.httplistener.aspx
            // for more information.
            string url = "http://localhost:8089";
            using (WebApp.Start(url))
            {
                Console.WriteLine("Server running on {0}", url);
                while (true)
                {
                    string key = Console.ReadLine();
                    if (key.ToUpper() == "W")
                    {
                        IHubContext hubContext = GlobalHost.ConnectionManager.GetHubContext<MyHub>();
                        hubContext.Clients.All.addMessage("server", "ServerMessage");
                        Console.WriteLine("Server Sending addMessage\n");
                    }
                    if (key.ToUpper() == "E")
                    {
                        IHubContext hubContext = GlobalHost.ConnectionManager.GetHubContext<MyHub>();
                        hubContext.Clients.All.heartbeat();
                        Console.WriteLine("Server Sending heartbeat\n");
                    }
                    if (key.ToUpper() == "R")
                    {
                        IHubContext hubContext = GlobalHost.ConnectionManager.GetHubContext<MyHub>();

                        var vv = new HelloModel {Age = 37, Molly = "pushed direct from Server "};

                        hubContext.Clients.All.sendHelloObject(vv);
                        Console.WriteLine("Server Sending sendHelloObject\n");
                    }
                    if (key.ToUpper() == "C")
                    {
                        break;
                    }
                }

                Console.ReadLine();
            }
        }
Exemple #34
0
 public void SendHelloObject(HelloModel hello)
 {
     Console.WriteLine("Hub hello {0} {1}\n", hello.Molly, hello.Age );
     Clients.All.sendHelloObject(hello);
 }