Esempio n. 1
0
        public async Task <IHttpActionResult> PutSettingsPause(int id, SettingsPause settingsPause)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != settingsPause.Id)
            {
                return(BadRequest());
            }

            db.Entry(settingsPause).State = EntityState.Modified;

            try
            {
                await db.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!SettingsPauseExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
Esempio n. 2
0
        public async Task <IHttpActionResult> GetSettingsPause(int id)
        {
            SettingsPause settingsPause = await db.SettingsPauses.FindAsync(id);

            if (settingsPause == null)
            {
                return(NotFound());
            }

            return(Ok(settingsPause));
        }
Esempio n. 3
0
        public async Task <IHttpActionResult> PostSettingsPause(SettingsPause settingsPause)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.SettingsPauses.Add(settingsPause);
            await db.SaveChangesAsync();

            return(CreatedAtRoute("DefaultApi", new { id = settingsPause.Id }, settingsPause));
        }
Esempio n. 4
0
        public async Task <bool> RegisterSettingsPause(SettingsPause pause)
        {
            var json       = JsonConvert.SerializeObject(pause);
            var httpClient = new HttpClient();
            var content    = new StringContent(json, Encoding.UTF8, "application/json");

            httpClient.DefaultRequestHeaders.Authorization = new System.Net.Http.Headers.AuthenticationHeaderValue("bearer", Settings.Accesstoken);
            var settingsApiUrl = "http://calendaradhd.azurewebsites.net/api/SettingsPauses/PostSettingsPause";
            var response       = await httpClient.PostAsync(settingsApiUrl, content);

            return(response.IsSuccessStatusCode);
        }
Esempio n. 5
0
        public async Task Test_Add_SettingsPause_Async()
        {
            ApiServices apiServices = new ApiServices();

            var pause = new SettingsPause()
            {
                MinPauseBeforeActivity = 10,
                CalendarUserEmail      = "*****@*****.**"
            };
            bool response = await apiServices.RegisterSettingsPause(pause);

            Assert.IsNotNull(response);
        }
Esempio n. 6
0
        public async Task <IHttpActionResult> DeleteSettingsPause(int id)
        {
            SettingsPause settingsPause = await db.SettingsPauses.FindAsync(id);

            if (settingsPause == null)
            {
                return(NotFound());
            }

            db.SettingsPauses.Remove(settingsPause);
            await db.SaveChangesAsync();

            return(Ok(settingsPause));
        }
Esempio n. 7
0
        private async void BtnSignUp_OnClicked(object sender, EventArgs e)
        {
            ApiServices apiServices = new ApiServices();

            var pause = new SettingsPause()
            {
                MinPauseBeforeActivity = Convert.ToInt32(EntMin.Text),
                CalendarUserEmail      = _email
            };
            bool response = await apiServices.RegisterSettingsPause(pause);

            if (response == true)
            {
                await DisplayAlert("Hej", "Tid för vila registrerat!", "Ok");

                await Navigation.PopToRootAsync();
            }
            else
            {
                await DisplayAlert("Oops", "Något gick fel!", "Ok");

                await Navigation.PopToRootAsync();
            }
        }