| | | 1 | | using KT.Modules.Report.Presentation.Dto; |
| | | 2 | | using MongoDB.Bson; |
| | | 3 | | using MongoDB.Bson.Serialization.Attributes; |
| | | 4 | | |
| | | 5 | | namespace KT.Modules.Report.Core.Domain |
| | | 6 | | { |
| | | 7 | | |
| | | 8 | | public enum Locality |
| | | 9 | | { |
| | | 10 | | Usaquen = 1, |
| | | 11 | | Chapinero = 2, |
| | | 12 | | SantaFe = 3, |
| | | 13 | | SanCristobal = 4, |
| | | 14 | | Usme = 5, |
| | | 15 | | Tunjuelito = 6, |
| | | 16 | | Bosa = 7, |
| | | 17 | | Kennedy = 8, |
| | | 18 | | Fontibon = 9, |
| | | 19 | | Engativa = 10, |
| | | 20 | | Suba = 11, |
| | | 21 | | BarriosUnidos = 12, |
| | | 22 | | Teusaquillo = 13, |
| | | 23 | | LosMartires = 14, |
| | | 24 | | AntonioNariño = 15, |
| | | 25 | | PuenteAranda = 16, |
| | | 26 | | LaCandelaria = 17, |
| | | 27 | | RafaelUribeUribe = 18, |
| | | 28 | | CiudadBolivar = 19, |
| | | 29 | | Sumapaz = 20 |
| | | 30 | | } |
| | | 31 | | |
| | | 32 | | public enum ReportType |
| | | 33 | | { |
| | | 34 | | Robbery = 1, |
| | | 35 | | Kidnapping = 2, |
| | | 36 | | Fight = 3, |
| | | 37 | | SexualHarassment = 4, |
| | | 38 | | Extortion = 5, |
| | | 39 | | } |
| | | 40 | | |
| | | 41 | | internal class Location |
| | | 42 | | { |
| | 19 | 43 | | public required float Latitude { get; set; } |
| | 19 | 44 | | public required float Longitude { get; set; } |
| | 19 | 45 | | public required Locality Locality { get; set; } |
| | 19 | 46 | | public required string Neighbourhood { get; set; } |
| | | 47 | | } |
| | | 48 | | |
| | | 49 | | internal class Report |
| | | 50 | | { |
| | | 51 | | [BsonId] |
| | | 52 | | public string? Id { get; set; } = ObjectId.GenerateNewId().ToString(); |
| | | 53 | | public required string UserId { get; set; } |
| | | 54 | | |
| | | 55 | | public required ReportType Type { get; set; } |
| | | 56 | | |
| | | 57 | | public required Location Location { get; set; } |
| | | 58 | | public required string Title { get; set; } |
| | | 59 | | public required string Description { get; set; } |
| | | 60 | | public required DateTime CreatedAt { get; set; } |
| | | 61 | | public DateTime UpdatedAt { get; set; } |
| | | 62 | | |
| | | 63 | | internal static Report FromCreateDto(RequestCreateReportDto requestReport) |
| | | 64 | | { |
| | | 65 | | var location = new Location |
| | | 66 | | { |
| | | 67 | | Latitude = requestReport.Location.Latitude, |
| | | 68 | | Longitude = requestReport.Location.Longitude, |
| | | 69 | | Locality = requestReport.Location.Locality, |
| | | 70 | | Neighbourhood = requestReport.Location.Neighbourhood |
| | | 71 | | }; |
| | | 72 | | |
| | | 73 | | return new Report |
| | | 74 | | { |
| | | 75 | | UserId = requestReport.UserId, |
| | | 76 | | Location = location, |
| | | 77 | | Type = requestReport.Type, |
| | | 78 | | Description = requestReport.Description, |
| | | 79 | | Title = requestReport.Title, |
| | | 80 | | CreatedAt = DateTime.Now |
| | | 81 | | }; |
| | | 82 | | } |
| | | 83 | | |
| | | 84 | | internal ReportDto toReportDto() { |
| | | 85 | | var location = new LocationDto |
| | | 86 | | { |
| | | 87 | | Latitude = this.Location.Latitude, |
| | | 88 | | Longitude = this.Location.Longitude, |
| | | 89 | | Locality = this.Location.Locality, |
| | | 90 | | Neighbourhood = this.Location.Neighbourhood |
| | | 91 | | }; |
| | | 92 | | return new ReportDto |
| | | 93 | | { |
| | | 94 | | Id = this.Id, |
| | | 95 | | Location = location, |
| | | 96 | | Type = this.Type, |
| | | 97 | | Description = this.Description, |
| | | 98 | | Title = this.Title, |
| | | 99 | | CreatedAt = this.CreatedAt, |
| | | 100 | | UpdatedAt = this.UpdatedAt, |
| | | 101 | | }; |
| | | 102 | | } |
| | | 103 | | } |
| | | 104 | | } |