This repository was archived by the owner on Feb 8, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathChatLog.cs
More file actions
140 lines (122 loc) · 4 KB
/
ChatLog.cs
File metadata and controls
140 lines (122 loc) · 4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
using System.Text.Json;
using System.Text.Json.Serialization;
using JGP.Telegram.Core.Commands;
namespace JGP.Telegram.Core;
/// <summary>
/// Class chat log
/// </summary>
/// <seealso cref="IEquatable{ChatLog}" />
/// <seealso cref="IEqualityComparer{ChatLog}" />
public class ChatLog : IEquatable<ChatLog>, IEqualityComparer<ChatLog>
{
/// <summary>
/// Initializes a new instance of the <see cref="ChatLog" /> class
/// </summary>
protected ChatLog()
{
}
/// <summary>
/// Initializes a new instance of the <see cref="ChatLog" /> class
/// </summary>
/// <param name="command">The command</param>
public ChatLog(ChatLogCreateCommand command)
{
Id = Guid.NewGuid();
ChatId = command.ChatId;
MessageDate = DateTimeOffset.UtcNow;
Request = command.Request;
Response = command.Response;
}
/// <summary>
/// Gets or sets the value of the id
/// </summary>
/// <value>System.Guid</value>
public Guid Id { get; protected set; }
/// <summary>
/// Gets or sets the value of the chat id
/// </summary>
/// <value>System.String</value>
public string ChatId { get; protected set; }
/// <summary>
/// Gets or sets the value of the message date
/// </summary>
/// <value>System.DateTimeOffset</value>
public DateTimeOffset MessageDate { get; protected set; }
/// <summary>
/// Gets or sets the value of the request
/// </summary>
/// <value>System.Nullable<string></value>
public string? Request { get; protected set; }
/// <summary>
/// Gets or sets the value of the response
/// </summary>
/// <value>System.Nullable<string></value>
public string? Response { get; protected set; }
#region OVERRIDES & ESSENTIALS
/// <summary>
/// Describes whether this instance equals
/// </summary>
/// <param name="other">The other</param>
/// <returns>Interop+BOOL</returns>
public bool Equals(ChatLog? other)
{
if (other is null) return false;
return Id == other.Id
&& ChatId == other.ChatId
&& MessageDate == other.MessageDate
&& Request == other.Request
&& Response == other.Response;
}
/// <summary>
/// Describes whether this instance equals
/// </summary>
/// <param name="obj">The obj</param>
/// <returns>Interop+BOOL</returns>
public override bool Equals(object? obj)
{
if (obj is null) return false;
if (ReferenceEquals(this, obj)) return true;
if (obj.GetType() != GetType()) return false;
return obj is ChatLog other && Equals(other);
}
/// <summary>
/// Describes whether this instance equals
/// </summary>
/// <param name="x">The </param>
/// <param name="y">The </param>
/// <returns>Interop+BOOL</returns>
public bool Equals(ChatLog? x, ChatLog? y)
{
return x?.Equals(y) ?? false;
}
/// <summary>
/// Returns a hash code for this instance.
/// </summary>
/// <returns>A hash code for this instance, suitable for use in hashing algorithms and data structures like a hash table.</returns>
public override int GetHashCode()
{
return Id.GetHashCode();
}
/// <summary>
/// Gets the hash code using the specified obj
/// </summary>
/// <param name="obj">The obj</param>
/// <returns>int</returns>
public int GetHashCode(ChatLog obj)
{
return obj.GetHashCode();
}
/// <summary>
/// Returns a <see cref="System.String" /> that represents this instance.
/// </summary>
/// <returns>A <see cref="System.String" /> that represents this instance.</returns>
public override string ToString()
{
var options = new JsonSerializerOptions
{
DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull
};
return JsonSerializer.Serialize(this, options);
}
#endregion
}