public async Task <bool> AddDefendantAsync(string firstName, string lastName, string middleName, string attorney, string address, int?caseId) { var client = new HttpClient(GetInsecureHandler()); var model = new Defendants { FirstName = firstName, LastName = lastName, MiddleName = middleName, Attorney = attorney, Address = address, CaseId = caseId }; var json = JsonConvert.SerializeObject(model); HttpContent content = new StringContent(json); content.Headers.ContentType = new MediaTypeHeaderValue("application/json"); var response = await client.PostAsync($"{BaseUrl}/defendants", content); return(response.IsSuccessStatusCode); }
public EditDefendantPage(Defendants defendantObject) { InitializeComponent(); if (Device.RuntimePlatform == Device.macOS) { MobileEditDefendantForm.IsVisible = false; DesktopEditDefendantForm.IsVisible = true; } else { MobileEditDefendantForm.IsVisible = true; DesktopEditDefendantForm.IsVisible = false; if (Device.RuntimePlatform == Device.Android) { MobileCustomTextarea.BackgroundColor = Color.Transparent; } else { MobileCustomTextarea.BorderColor = Color.LightGray; } } BindingContext = defendantObject; }
public ActionResult <Defendants> EditDefendant(long id, Defendants editDefendant) { var editableDefendant = _context.Defendants.Find(id); _context.Defendants.Update(editableDefendant).CurrentValues.SetValues(editDefendant); _context.SaveChanges(); return(Ok()); }
void EditButton_Clicked(object sender, EventArgs e) { Defendants ToBeEdited = ((Button)sender).CommandParameter as Defendants; Navigation.PushAsync(new EditDefendantPage(ToBeEdited)); }
public ActionResult <Defendants> Create(Defendants newDefendant) { _context.Defendants.Add(newDefendant); _context.SaveChanges(); return(Ok()); }