public job_numbers CreateJobNumbers(string p, Guid user_token) { using (var context = new CWTimeclockEntities()) { var user = context.users.FirstOrDefault(f => f.token == user_token); if (user != null) { job_numbers j = new job_numbers(); j.job_number = p; j.id = Guid.NewGuid(); j.user_id = user_token; context.job_numbers.Add(j); context.SaveChanges(); return j; } else { throw new UserNotFoundException("Couldn't find user for token."); } } }
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; } }