public void UpdateFaultTypesSelections(FunctionalArea functionalArea) { if (functionalArea is null) { return; } var faultTypeSettings = functionalArea.FaultTypes.ToDictionary(x => x.Id, x => x.IsSelected); var functionalAreaFaultTypes = _dbContext.Query <Entities.Tenant.FunctionalAreas.FunctionalAreaFaultType>() .Where(x => x.FunctionalAreaId == functionalArea.Id) .ToList(); foreach (var functionalAreaFaultType in functionalAreaFaultTypes) { if (faultTypeSettings.ContainsKey(functionalAreaFaultType.FaultTypeId) && faultTypeSettings[functionalAreaFaultType.FaultTypeId] != functionalAreaFaultType.IsSelected) { functionalAreaFaultType.IsSelected = faultTypeSettings[functionalAreaFaultType.FaultTypeId]; _dbContext.Update(functionalAreaFaultType); } } }
public void Add(FunctionalArea functionalArea) => _dbContext.Add(_mapper.Map <Entities.Tenant.FunctionalAreas.FunctionalArea>(functionalArea));