public ComponentTypeTO Add(ComponentTypeTO Entity) { if (Entity is null) { throw new ArgumentNullException(nameof(Entity)); } return(facilityContext.ComponentTypes .Add(Entity.ToEF()) .Entity .ToTransfertObject()); }
public ComponentTypeTO Update(ComponentTypeTO Entity) { if (Entity is null) { throw new ArgumentNullException(nameof(Entity)); } if (!facilityContext.ComponentTypes.Any(x => x.Id == Entity.Id && x.Archived != true)) { throw new LoggedException($"ComponentTypeRepository. Update(ComponentTypeTransfertObject) no record to update."); } var attachedComponentTypes = facilityContext.ComponentTypes .FirstOrDefault(x => x.Id == Entity.Id && x.Archived != true); if (attachedComponentTypes != default) { attachedComponentTypes.UpdateFromDetached(Entity.ToEF()); } return(facilityContext.ComponentTypes.Update(attachedComponentTypes).Entity.ToTransfertObject()); }