Exemplo n.º 1
0
        private async Task<entry> _createJobEntry(entry e, Guid user_token)
        {
            using (var client = GetHttpClient())
            {
                if (e.time_to == DateTime.MinValue)
                {
                    e.time_to = e.time_from;
                }

                var payload = new WrapWithToken { payload = e, user_token = user_token };
                HttpResponseMessage response = client.PostAsJsonAsync(EntrysEndpoint, payload).Result;

                if (response.IsSuccessStatusCode)
                {
                    return await response.Content.ReadAsAsync<entry>();
                }
                else
                {

                }
                return null;
            }
        }
Exemplo n.º 2
0
        private async Task<job_numbers> _createJobNumbers(string job_number, Guid user_token)
        {

            using (var client = GetHttpClient())
            {
               
                job_numbers j = new job_numbers { job_number = job_number };


                var payload = new WrapWithToken { payload = j, user_token = user_token };
                HttpResponseMessage response = client.PostAsJsonAsync(JobNumbersEndpoint, payload).Result;

                if (response.IsSuccessStatusCode)
                {
                    return await response.Content.ReadAsAsync<job_numbers>();
                }
                else
                {

                }
                return null;
            }
        }
Exemplo n.º 3
0
        private async Task<bool> _updateEntry(Guid entryToken, string comments, Guid user_token)
        {
            using (var client = GetHttpClient())
            {
                entry E = new entry();
                E.id = entryToken;
                E.time_to = DateTime.Now;
                E.comments = comments;
               

                var payload = new WrapWithToken { payload = E, user_token = user_token };

                HttpResponseMessage response = client.PutAsJsonAsync("/api/entries/?entry_token=" + entryToken.ToString(), payload).Result;
                if (response.IsSuccessStatusCode)
                {
                    return await response.Content.ReadAsAsync<bool>();
                }
            }
            return false;
        }
Exemplo n.º 4
0
        private async Task<work_types> _createWorkType(string work_type, Guid user_token)
        {
            using (var client = GetHttpClient())
            {
                work_types j = new work_types { work_type = work_type };


                var payload = new WrapWithToken { payload = j, user_token = user_token };
                HttpResponseMessage response = client.PostAsJsonAsync(WorkTypesEndpoint, payload).Result;

                if (response.IsSuccessStatusCode)
                {
                    return await response.Content.ReadAsAsync<work_types>();
                }
                else
                {

                }
                return null;
            }
        }