< Summary

Information
Class: KT.Modules.Report.Presentation.Dto.WebSocket.ReportDataDelete
Assembly: KT.Modules.Report
File(s): G:\NetProjects\KeepTrack\src\Modules\KT.Modules.Report\Core\Application\ReportNotification.cs
Line coverage
14%
Covered lines: 1
Uncovered lines: 6
Coverable lines: 7
Total lines: 101
Line coverage: 14.2%
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%
fromDomain(...)100%210%

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    {
 22        public required string Id { get; set; }
 23        public string UserId { get; set; }
 24        public LocationAdd Location { get; set; }
 25        public ReportType Type { get; set; }
 26        public string? Description { get; set; }
 27        public string? Title { get; set; }
 28        public DateTime CreatedAt { get; set; }
 29        public DateTime UpdatedAt { get; set; }
 30
 31        public static ReportDataAdd fromDomain (Core.Domain.Report report)
 32        {
 33            var location = new LocationAdd
 34            {
 35                Latitude = report.Location.Latitude,
 36                Longitude = report.Location.Longitude,
 37                Locality = report.Location.Locality,
 38                Neighbourhood = report.Location.Neighbourhood
 39            };
 40
 41            return new ReportDataAdd
 42            {
 43                Id = report.Id,
 44                UserId = report.UserId,
 45                Location = location,
 46                Type = report.Type,
 47                Description = report.Description,
 48                Title = report.Title,
 49                CreatedAt = report.CreatedAt,
 50                UpdatedAt = report.UpdatedAt,
 51            };
 52        }
 53    }
 54
 55    internal class ReportDataDelete : ReportData
 56    {
 257        public required string Id { get; set; }
 58
 59        public static ReportDataDelete fromDomain(Core.Domain.Report report)
 060        {
 061            return new ReportDataDelete
 062            {
 063                Id = report.Id,
 064            };
 065        }
 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}