private async Task LoadSolvedOccurredIncidents()
        {
            // Alle opgeloste incidenten ophalen
            var solvedOccurredIncidentsOriginal            = (await _occurredIncidentDataService.GetAllSolvedOccurredIncidentsAsync()).ToList();
            IList <OccurredIncident> tempOccurredIncidents = new List <OccurredIncident>();

            // Voor ieder opgelost incident een nieuw OccurredIncident-object aanmaken met enkele andere gegevens (deze moeten getoond worden in UI)
            foreach (OccurredIncident incident in solvedOccurredIncidentsOriginal)
            {
                await InitDeviceById(incident.DeviceId);

                OccurredIncident occurredIncident = new OccurredIncident
                {
                    OccurredIncidentId  = incident.OccurredIncidentId,
                    DeviceId            = incident.DeviceId,
                    DeviceName          = _tempDevice.Name,
                    DeviceLocation      = _tempDevice.Location,
                    IncidentDescription = incident.IncidentDescription,
                    CurrentUserId       = incident.CurrentUserId,
                    UserName            = await GetUserNameById(incident.CurrentUserId),
                    Solved = incident.Solved
                };

                // Nieuw OccurredIncident-object toevoegen aan de lijst
                tempOccurredIncidents.Add(occurredIncident);
            }

            SolvedOccurredIncidents = tempOccurredIncidents;
        }
        // Command methods
        public async void MarkAsUnsolved()
        {
            Message = "";

            if (_selectedOccurredIncident == null)
            {
                Message = "Selecteer een incident";
            }
            else
            {
                await _occurredIncidentDataService.SetOccurredIncidentUnsolvedAsync(_selectedOccurredIncident.OccurredIncidentId);

                _selectedOccurredIncident = null;
                Message = "Het geselecteerde incident is succesvol gemarkeerd als 'niet opgelost'";

                // De lijst refreshen
                await Task.Delay(1000);
                await LoadSolvedOccurredIncidents();
            }
        }
예제 #3
0
        public IActionResult Add([FromBody] OccurredIncident newOccurredIncident)
        {
            OccurredIncident occurredIncident = null;

            if (ModelState.IsValid)
            {
                occurredIncident = new OccurredIncident()
                {
                    OccurredIncidentId  = newOccurredIncident.OccurredIncidentId,
                    IncidentDescription = newOccurredIncident.IncidentDescription,
                    CurrentUserId       = newOccurredIncident.CurrentUserId,
                    Solved   = newOccurredIncident.Solved,
                    DeviceId = newOccurredIncident.DeviceId
                };
            }

            if (occurredIncident != null)
            {
                _occurredIncidentData.Add(newOccurredIncident);
                return(Ok());
            }

            return(BadRequest());
        }
예제 #4
0
 public void Add(OccurredIncident newOccurredIncident)
 {
     _context.Add(newOccurredIncident);
     _context.SaveChanges();
 }