public ActionResult <Incident> Put(int id, [FromBody] Incident incident) { try { incident.Id = id; return(Ok(_incidentService.UpdateIncident(incident))); } catch (Exception e) { return(BadRequest(e.Message)); } }
private async void SaveIncident() { try { var res = 0; if (!CanSave) { await _pageDialogService.DisplayAlertAsync("Missing info", "Select a type and enter report details", "OK"); return; // I know it's bad but I'm tired and INPC is not working in the button, need to investigate } if (SelectedIncident.IncId == 0) { res = await _incidentService.AddIncident(SelectedIncident); } else { res = await _incidentService.UpdateIncident(SelectedIncident); } if (res > 0) { await _navigationService.GoBackAsync(new NavigationParameters { { NavigationParams.PageRefresh, null } }, animated : false); } else { await _pageDialogService.DisplayAlertAsync("Error", "incident could not be saved", "OK"); } } catch (Exception ex) { await _pageDialogService.DisplayAlertAsync("Error", ex.Message, "OK"); throw; } }