1: using System;
2: using System.ComponentModel.DataAnnotations;
3: using System.ComponentModel.DataAnnotations.Schema;
4:
5: namespace Ia.TentPlay.Cl.Model.Nfc
6: {
7: ////////////////////////////////////////////////////////////////////////////
8:
9: /// <summary publish="true">
10: /// TAG NFC Near-Field Communication (NFC) Support Entity functions
11: /// </summary>
12: /// <remarks>
13: /// Copyright © 2020-2021 Jasem Y. Al-Shamlan (info@ia.com.kw), Integrated Applications - Kuwait. All Rights Reserved.
14: ///
15: /// This library is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by
16: /// the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
17: ///
18: /// This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
19: /// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
20: ///
21: /// You should have received a copy of the GNU General Public License along with this library. If not, see http://www.gnu.org/licenses.
22: ///
23: /// Copyright notice: This notice may not be removed or altered from any source distribution.
24: /// </remarks>
25: public partial class Tag
26: {
27: ////////////////////////////////////////////////////////////////////////////
28:
29: /// <summary>
30: ///
31: /// </summary>
32: public Tag() { }
33:
34: /// <summary/>
35: [Key, DatabaseGenerated(DatabaseGeneratedOption.None)]
36: public string Id { get; set; }
37:
38: /// <summary/>
39: public string UId { get; set; }
40:
41: /// <summary/>
42: public int TypeId { get; set; }
43:
44: /// <summary/>
45: public int ProjectId { get; set; }
46:
47: /// <summary/>
48: public int Counter { get; set; }
49:
50: /// <summary/>
51: public string Payload { get; set; }
52:
53: /// <summary/>
54: public DateTime Created { get; set; }
55:
56: /// <summary/>
57: public DateTime Updated { get; set; }
58:
59: /// <summary/>
60: public DateTime Interacted { get; set; }
61:
62: /// <summary/>
63: public System.Guid UserId { get; set; }
64:
65: ////////////////////////////////////////////////////////////////////////////
66:
67: /// <summary>
68: ///
69: /// </summary>
70: public bool Update(Tag updatedTag)
71: {
72: // below: this will not update Id, UIdm TypeId, ProjectId, Created
73: bool updated;
74:
75: updated = false;
76:
77: if (this.Counter != updatedTag.Counter) { this.Counter = updatedTag.Counter; updated = true; }
78: if (this.Payload != updatedTag.Payload) { this.Payload = updatedTag.Payload; updated = true; }
79:
80: //if (this.Inventory != updatedTag.Inventory) { this.Inventory = updatedTag.Inventory; updated = true; }
81:
82: if (this.UserId != updatedTag.UserId) { this.UserId = updatedTag.UserId; updated = true; }
83:
84: if (updated) this.Updated = DateTime.UtcNow.AddHours(3);
85:
86: // I will check Interacted after Updated to make sure Updated is only for when there is change in Counter or Payload
87: if (this.Interacted != updatedTag.Interacted) { this.Interacted = updatedTag.Interacted; updated = true; }
88:
89: return updated;
90: }
91:
92: ////////////////////////////////////////////////////////////////////////////
93: ////////////////////////////////////////////////////////////////////////////
94: }
95:
96: ////////////////////////////////////////////////////////////////////////////
97: ////////////////////////////////////////////////////////////////////////////
98: }