Exemplo n.º 1
0
        static void Main(string[] args)
        {
            WeatherService.WeatherService weatherServiceClient = new WeatherService.WeatherService();
            var weatherResults = weatherServiceClient.ConvertCelciusToFahrenheit(30);

            WindsorContainer Container = new WindsorContainer();

            Container.AddFacility <WcfFacility>();

            Container.Register(
                Component.For <IRepository <Employee> >().ImplementedBy <Repository <Employee> >()
                );
            IEmployeeRepository _employeeRepository = Container.Resolve <EmployeeRepository>();

            WcfServiceHost.EmployeeService employeeServiceClient = new WcfServiceHost.EmployeeService(_employeeRepository);
            var employees = employeeServiceClient.GetEmployees();

            var emp = new Employee();

            emp.Name        = "CiaranMary";
            emp.Gender      = "Male";
            emp.DateOfBirth = Convert.ToDateTime("08/12/1982");
            employeeServiceClient.AddEmployee(emp);

            // var testEmployee = employeeServiceClient.GetEmployee(emp);
        }
Exemplo n.º 2
0
        /// <summary>
        /// POST: api/Messages
        /// Receive a message from a user and reply to it
        /// </summary>
        public async Task <HttpResponseMessage> Post([FromBody] Activity activity)
        {
            if (activity.Type == ActivityTypes.Message)
            {
                if (activity.MentionsRecipient())
                {
                    ConnectorClient connector = new ConnectorClient(new Uri(activity.ServiceUrl));

                    // Show typing while performing lookups
                    var typingActivity = activity.CreateReply();
                    typingActivity.Type = ActivityTypes.Typing;
                    await connector.Conversations.ReplyToActivityAsync(typingActivity);

                    // Remove the mention from the activity text
                    var cityName = activity.RemoveRecipientMention();

                    var locatorService = new GeoLocatorService.GeoService();
                    var matches        = await locatorService.FindCoordinates(cityName);

                    if (matches.Count == 0)
                    {
                        await connector.Conversations.ReplyToActivityAsync(activity.CreateReply("Couldn't find the weather!"));
                    }
                    else if (matches.Count == 1)
                    {
                        var weather = new WeatherService.WeatherService();
                        var current = await weather.GetCurrentConditions(matches[0].Latitude, matches[0].Longitude);

                        var reply = activity.CreateReply($"The current conditions for {matches[0].CityState} are {current.Summary} and {current.CurrentTemp}.");

                        await connector.Conversations.ReplyToActivityAsync(reply);
                    }
                    else
                    {
                        var cityHero = new HeroCard();
                        cityHero.Title    = "Which city?";
                        cityHero.Subtitle = $"Multiple cities found for {cityName}";
                        cityHero.Text     = "Select which city you want the weather for:";
                        cityHero.Buttons  = new List <CardAction>();

                        foreach (var city in matches)
                        {
                            var cityAction = new CardAction();
                            cityAction.Type  = ActionTypes.PostBack;
                            cityAction.Value = city.CityState;
                            cityAction.Title = city.CityState;

                            cityHero.Buttons.Add(cityAction);
                        }

                        var cityHeroReply = activity.CreateReply();
                        cityHeroReply.Attachments = new List <Attachment>();
                        cityHeroReply.Attachments.Add(cityHero.ToAttachment());

                        await connector.Conversations.ReplyToActivityAsync(cityHeroReply);
                    }
                }
            }
            else
            {
                HandleSystemMessage(activity);
            }
            var response = Request.CreateResponse(HttpStatusCode.OK);

            return(response);
        }