From fb8f49a2f6bfad81352892df56f676abd527df9b Mon Sep 17 00:00:00 2001 From: Arnaud Dartois Date: Fri, 17 Jul 2026 20:03:23 +0000 Subject: [PATCH] refactor(domain): remove redundant Camera.Update call in CreateAsync Camera constructor now accepts Manufacturer and Model directly, so the redundant Update() call in CameraService is no longer needed. --- src/Heimdall.Domain/Entities/Camera.cs | 4 +++- src/Heimdall.Infrastructure/Services/CameraService.cs | 3 +-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/Heimdall.Domain/Entities/Camera.cs b/src/Heimdall.Domain/Entities/Camera.cs index 3ae91d8..a68bab4 100644 --- a/src/Heimdall.Domain/Entities/Camera.cs +++ b/src/Heimdall.Domain/Entities/Camera.cs @@ -34,12 +34,14 @@ public class Camera : Entity, IAuditableEntity, ISoftDeletable private Camera() { } // EF Core - public Camera(Guid siteId, string name, string? rtspUrl = null) + public Camera(Guid siteId, string name, string? rtspUrl = null, string? manufacturer = null, string? model = null) : base(Guid.NewGuid()) { SiteId = siteId; Name = name; RtspUrl = rtspUrl; + Manufacturer = manufacturer; + Model = model; } public void AssignAgent(Guid agentId) => AgentId = agentId; diff --git a/src/Heimdall.Infrastructure/Services/CameraService.cs b/src/Heimdall.Infrastructure/Services/CameraService.cs index fdf4c15..53d1d34 100644 --- a/src/Heimdall.Infrastructure/Services/CameraService.cs +++ b/src/Heimdall.Infrastructure/Services/CameraService.cs @@ -20,8 +20,7 @@ public class CameraService : ICameraService if (site is null) return ServiceResult.NotFound("Site not found"); - var camera = new Camera(request.SiteId, request.Name, request.RtspUrl); - camera.Update(request.Name, request.Manufacturer, request.Model, request.RtspUrl); + var camera = new Camera(request.SiteId, request.Name, request.RtspUrl, request.Manufacturer, request.Model); _db.Cameras.Add(camera); await _db.SaveChangesAsync(ct);