Esempio n. 1
0
        private async void submitBtn_Clicked(object sender, EventArgs e)
        {
            TimeSpan t = timePicker.Time;
            DateTime d = datePicker.Date;
            DateTime appointmentTime = d + t;

            string time           = appointmentTime.ToString("HH:mm");
            string date           = appointmentTime.ToString("ddd");
            string dateTimeString = date + "dag kl. " + time;


            var selection = await DisplayAlert("Ny aftale?", "Ønsker du at oprette en aftale " + dateTimeString + "?", "OK", "Annuller");

            if (selection == true)
            {
                MomlyFriend momlyFriend = new MomlyFriend();
                momlyFriend.Age            = 35;
                momlyFriend.BabyAgeInMonth = 8;
                momlyFriend.UserName       = "******";
                momlyFriend.PlannedWalk    = appointmentTime;
                momlyFriend.Latitude       = Location[0];
                momlyFriend.Longtitude     = Location[1];

                RestService restService = new RestService();
                string      response    = await restService.CreateMomlyActivity(momlyFriend);

                await Navigation.PopAsync();
            }

            if (selection == false)
            {
                return;
            }
        }
Esempio n. 2
0
        public async Task <string> CreateMomlyActivity(MomlyFriend momlyFriend)
        {
            var uri = new Uri(string.Format(restUrl, "api/walk"));

            var json    = JsonConvert.SerializeObject(momlyFriend);
            var content = new StringContent(json, Encoding.UTF8, "application/json");

            HttpResponseMessage response = null;

            response = await client.PostAsync(uri, content);

            if (response.IsSuccessStatusCode)
            {
                return("OK");
            }

            return("Error");
        }
Esempio n. 3
0
        private string GetText(string userName)
        {
            MomlyFriend friend = momlyFriends.Where(x => x.UserName == userName).FirstOrDefault();

            StringBuilder builder = new StringBuilder();

            builder.Append($"{friend.UserName} er {friend.Age} år. ");
            if (friend.BabyAgeInMonth > -1)
            {
                builder.Append($"Hendes baby er {friend.BabyAgeInMonth} måneder.");
            }

            string time = " kl. " + friend.PlannedWalk.ToString("HH:mm");
            string date = friend.PlannedWalk.ToString("ddd") + "dag";

            string dateTimeString = date + time;

            builder.Append("\n" + friend.UserName + " ønsker en at gå tur med " + dateTimeString);

            return(builder.ToString());
        }