예제 #1
0
 private async void createProject(ProjectViewModel project)
 {
     using (var client = new HttpClient())
     {
         client.DefaultRequestHeaders.Clear();
         client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
         string token = Properties.Settings.Default.ApiToken;
         client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token);
         string serialized = new JavaScriptSerializer().Serialize(project);
         var response = await client.PostAsync(ServiceURI + "/api/project/CreateProject", new StringContent(serialized, Encoding.UTF8, "application/json"));
         if (!response.IsSuccessStatusCode)
         {
             throw new Exception();
         }
     }
 }
예제 #2
0
 private async void createProjectButton_Click(object sender, EventArgs e)
 {
     await getProfile();
     listOfFriendsToProject.Add(user.Id);
     listOfFriendsToProject = listOfFriendsToProject.Distinct().ToList<int>();
     
     DateTime startDate = DateTime.Now;
     ProjectViewModel project = new ProjectViewModel(1, titleTextBox.Text, descriptionTextBox.Text, DateTime.Now, dateTimePicker1.Value, listOfFriendsToProject);
     createProject(project);
 }