< Summary

Information
Class: KT.Modules.Report.Presentation.Dto.WebSocket.ReportDataAdd
Assembly: KT.Modules.Report
File(s): G:\NetProjects\KeepTrack\src\Modules\KT.Modules.Report\Core\Application\ReportNotification.cs
Line coverage
100%
Covered lines: 28
Uncovered lines: 0
Coverable lines: 28
Total lines: 101
Line coverage: 100%
Branch coverage
N/A
Covered branches: 0
Total branches: 0
Branch coverage: N/A
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
get_Id()100%11100%
get_UserId()100%11100%
get_Location()100%11100%
get_Type()100%11100%
get_Description()100%11100%
get_Title()100%11100%
get_CreatedAt()100%11100%
get_UpdatedAt()100%11100%
fromDomain(...)100%11100%

File(s)

G:\NetProjects\KeepTrack\src\Modules\KT.Modules.Report\Core\Application\ReportNotification.cs

#LineLine coverage
 1using KT.Modules.Report.Core.Domain;
 2using System.Text.Json.Serialization;
 3
 4namespace KT.Modules.Report.Presentation.Dto.WebSocket
 5{
 6
 7    internal class LocationAdd
 8    {
 9        public float Latitude { get; set; }
 10        public float Longitude { get; set; }
 11        public Locality Locality { get; set; }
 12        public required string Neighbourhood { get; set; }
 13    }
 14    [JsonDerivedType(typeof(ReportDataAdd))]
 15    [JsonDerivedType(typeof(ReportDataDelete))]
 16    internal class ReportData
 17    {
 18
 19    }
 20    internal class ReportDataAdd : ReportData
 21    {
 222        public required string Id { get; set; }
 223        public string UserId { get; set; }
 224        public LocationAdd Location { get; set; }
 225        public ReportType Type { get; set; }
 226        public string? Description { get; set; }
 227        public string? Title { get; set; }
 228        public DateTime CreatedAt { get; set; }
 229        public DateTime UpdatedAt { get; set; }
 30
 31        public static ReportDataAdd fromDomain (Core.Domain.Report report)
 132        {
 133            var location = new LocationAdd
 134            {
 135                Latitude = report.Location.Latitude,
 136                Longitude = report.Location.Longitude,
 137                Locality = report.Location.Locality,
 138                Neighbourhood = report.Location.Neighbourhood
 139            };
 40
 141            return new ReportDataAdd
 142            {
 143                Id = report.Id,
 144                UserId = report.UserId,
 145                Location = location,
 146                Type = report.Type,
 147                Description = report.Description,
 148                Title = report.Title,
 149                CreatedAt = report.CreatedAt,
 150                UpdatedAt = report.UpdatedAt,
 151            };
 152        }
 53    }
 54
 55    internal class ReportDataDelete : ReportData
 56    {
 57        public required string Id { get; set; }
 58
 59        public static ReportDataDelete fromDomain(Core.Domain.Report report)
 60        {
 61            return new ReportDataDelete
 62            {
 63                Id = report.Id,
 64            };
 65        }
 66    }
 67
 68    internal enum ReportNotificaionType
 69    {
 70        CREATE = 0,
 71        UPDATE = 1,
 72        DELETE = 2,
 73    }
 74
 75    internal class  ReportNotification
 76    {
 77        public required ReportNotificaionType Type { get; set; }
 78        public required ReportData Report { get; set; }
 79
 80
 81
 82        public static ReportNotification Create (ReportData reportData, ReportNotificaionType type)
 83        {
 84            return new ReportNotification
 85            {
 86                Type = type,
 87                Report = reportData
 88            };
 89        }
 90
 91        public static ReportNotification DeleteReportNotification(string reportId)
 92        {
 93            return new ReportNotification
 94            {
 95                Type = ReportNotificaionType.DELETE,
 96                Report = new ReportDataDelete { Id = reportId }
 97            };
 98        }
 99    }
 100
 101}