{"action":"created","issue":{"url":"https://api.github.com/repos/volkanceylan/Serenity/issues/178","repository_url":"https://api.github.com/repos/volkanceylan/Serenity","labels_url":"https://api.github.com/repos/volkanceylan/Serenity/issues/178/labels{/name}","comments_url":"https://api.github.com/repos/volkanceylan/Serenity/issues/178/comments","events_url":"https://api.github.com/repos/volkanceylan/Serenity/issues/178/events","html_url":"https://github.com/volkanceylan/Serenity/issues/178","id":130472739,"number":178,"title":"Timestamp Designations and Field Lock on event. ","user":{"login":"sayuga","id":16759829,"avatar_url":"https://avatars.githubusercontent.com/u/16759829?v=3","gravatar_id":"","url":"https://api.github.com/users/sayuga","html_url":"https://github.com/sayuga","followers_url":"https://api.github.com/users/sayuga/followers","following_url":"https://api.github.com/users/sayuga/following{/other_user}","gists_url":"https://api.github.com/users/sayuga/gists{/gist_id}","starred_url":"https://api.github.com/users/sayuga/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sayuga/subscriptions","organizations_url":"https://api.github.com/users/sayuga/orgs","repos_url":"https://api.github.com/users/sayuga/repos","events_url":"https://api.github.com/users/sayuga/events{/privacy}","received_events_url":"https://api.github.com/users/sayuga/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2016-02-01T20:26:05Z","updated_at":"2016-02-05T16:23:35Z","closed_at":null,"body":"So, my brain has been spinning on how to best deal with this but I've been hitting a wall. I get the feeling it's something so simple I'm just missing it but I've probably just been staring at the coding much too long. \r\n\r\nHere is the premise: \r\n\r\nI have four 'DateTime' Fields and a 'Status' enumerated field. \r\n\r\n        [Category(\"Revisions\")]\r\n        public DateTime LastUpdated { get ; set; }\r\n        [Updatable(false)]\r\n        public DateTime AddedOn { get; set; }\r\n        public DateTime EditedOn { get; set; }\r\n        public DateTime RemovedOn { get; set; }\r\n        public Int32 Status { get; set; }\r\n\r\nNow, i will not be allowing the deletion of any records because we need to be able to audit everything thus I instead am Time stamping changes according to the \"Status\" field. \r\n\r\nStatus Field has 3 enumerations MatrixStatus.Added, MatrixStatus.Editted\" and MatrixStatus.Removed. \r\n\r\nEssentially, I need to accomplish the following. When a record is fist created, LastUpdate AND AddedOn Populate to Now(). AddedOn then becomes locked so it can't be updated Manually. I have \"Status\" field with DefaultValue(1), meaning MatrixStatus.Added, which is meant to be the trigger for the initial update. \r\n\r\nFrom that point onward, any change needs to be recorded by triggering the LastUpdated field with New() and either EditedOn or RemovedOn should be triggered as well whenever the \"Status\" field is changes to 2 (Editted) or 3 (Removed).\r\n\r\nAdditionally, when an item is set to Removed, it needs to be locked from updating. \r\n\r\nSo far I've been attempting to designate the restrictions on the TableForm.cs  file since it should only affect the form but not much success.\r\n\r\n  [Category(\"Revisions\")]\r\n        [Updatable(false)]\r\n        public DateTime LastUpdated\r\n        {\r\n            get { return LastUpdated; }\r\n            set\r\n            {\r\n                DateTime CurrentTime = DateTime.Today;\r\n\r\n                if (Status = MatrixStatus.Added)\r\n                { LastUpdated = CurrentTime; }\r\n\r\n                else if (Status = MatrixStatus.Removed)\r\n                { LastUpdated = CurrentTime; }\r\n\r\n                else if (Status = MatrixStatus.Updated)\r\n                { LastUpdated = CurrentTime;  }\r\n\r\n                else\r\n                { LastUpdated = value;   }\r\n            };\r\n        }\r\n\r\n                  ...\r\n//I reuse the same set up for AddedOn, EditedOn and RemovedOn\r\n            [Updatable(false)]\r\n        public DateTime AddedOn\r\n        {\r\n            get {  return AddedOn; }\r\n            set\r\n            {\r\n                DateTime CurrentTime = DateTime.Today;\r\n\r\n                if (Status = MatrixStatus.Added)\r\n                    {AddedOn = CurrentTime;}\r\n                else\r\n                    {AddedOn = value;}\r\n            };\r\n        }\r\n\r\nAny suggestions? Any way Serenity can implicitly default a date to a form? What about a fields lock trigger for whenever a field is no longer 'Null'?  "},"comment":{"url":"https://api.github.com/repos/volkanceylan/Serenity/issues/comments/180427965","html_url":"https://github.com/volkanceylan/Serenity/issues/178#issuecomment-180427965","issue_url":"https://api.github.com/repos/volkanceylan/Serenity/issues/178","id":180427965,"user":{"login":"sayuga","id":16759829,"avatar_url":"https://avatars.githubusercontent.com/u/16759829?v=3","gravatar_id":"","url":"https://api.github.com/users/sayuga","html_url":"https://github.com/sayuga","followers_url":"https://api.github.com/users/sayuga/followers","following_url":"https://api.github.com/users/sayuga/following{/other_user}","gists_url":"https://api.github.com/users/sayuga/gists{/gist_id}","starred_url":"https://api.github.com/users/sayuga/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sayuga/subscriptions","organizations_url":"https://api.github.com/users/sayuga/orgs","repos_url":"https://api.github.com/users/sayuga/repos","events_url":"https://api.github.com/users/sayuga/events{/privacy}","received_events_url":"https://api.github.com/users/sayuga/received_events","type":"User","site_admin":false},"created_at":"2016-02-05T16:23:35Z","updated_at":"2016-02-05T16:23:35Z","body":"I give. Could I have you provide me a sample when you have a moment? No immediate rush but help is appreciated. (I have it set to manual entry for the time being) \r\n\r\nI attempted to recreate the LoggingRow setup on the fields I needed but I'm getting nothing. It'll rebuild and transform properly and when I go to the item in question when running the item is locked from update but holds no data. Here is what I've done: \r\n\r\nI  added the following to the MatrixRow.cs:\r\n\r\n// ILoggingRow was added to class for logging test. \r\n    public sealed class MatrixRow : Row, IIdRow, INameRow, ILoggingRow \r\n\r\n...\r\n//Added Insertable(false), Updatable(false) to all DateTime fields\r\n      [DisplayName(\"Last Updated\"), Width(100), AlignCenter, NotNull, Insertable(false), Updatable(false)]\r\n        public DateTime? AddedOn\r\n        {\r\n            get { return Fields.AddedOn[this]; }\r\n            set { Fields.AddedOn[this] = value; }\r\n        }\r\n\r\n...\r\n\r\n        DateTimeField IInsertLogRow.InsertDateField\r\n        {\r\n            get { return Fields.LastUpdated; }\r\n\r\n        }\r\n\r\n        DateTimeField IUpdateLogRow.UpdateDateField\r\n        {\r\n            get { return Fields.LastUpdated; }\r\n        }\r\n\r\n   IIdField IUpdateLogRow.UpdateUserIdField\r\n        {\r\n            get\r\n            {\r\n                throw new NotImplementedException();\r\n            }\r\n        }\r\n\r\n        IIdField IInsertLogRow.InsertUserIdField\r\n        {\r\n            get\r\n            {\r\n                throw new NotImplementedException();\r\n            }\r\n        }\r\n"}}