public IncidentTO Update(IncidentTO Entity)
        {
            if (Entity is null)
            {
                throw new ArgumentNullException(nameof(Entity));
            }
            if (Entity.Id <= 0)
            {
                throw new ArgumentException("The Incident's ID is not in the correct format !");
            }

            if (!facilityContext.Incidents.Any(x => x.Id == Entity.Id))
            {
                throw new KeyNotFoundException("No incident found !");
            }

            var attachedIncident = facilityContext.Incidents
                                   .Include(i => i.Issue)
                                   .ThenInclude(i => i.ComponentType)
                                   .Include(i => i.Room)
                                   .ThenInclude(r => r.Floor)
                                   .FirstOrDefault(x => x.Id == Entity.Id);

            if (attachedIncident != null)
            {
                attachedIncident.UpdateFromDetached(Entity.ToEF());
            }

            var tracking = facilityContext.Incidents.Update(attachedIncident);

            tracking.State = EntityState.Detached;

            return(tracking.Entity.ToTransfertObject());
        }
        public IncidentTO Add(IncidentTO Entity)
        {
            if (Entity is null)
            {
                throw new ArgumentNullException(nameof(Entity));
            }

            var incident = Entity.ToEF();

            incident.Issue = facilityContext.Issues.First(x => x.Id == Entity.Issue.Id && x.Archived != true);
            incident.Room  = facilityContext.Rooms.First(x => x.Id == Entity.Room.Id && x.Archived != true);

            return(facilityContext.Incidents.Add(incident).Entity.ToTransfertObject());
        }