How to keep track of old versions of objects in .net core?

I was working on a project on ASP.NET Core where I had to keep track of edits to Contracts here is where I've come so far, Models -

  //Contract Model
  public class Contract
    {
        [Key]
        public int Id { get; set; }
        public string ContractId { get; set; }
    }




//Contrat History Model
   public class ContratEditHistory
    {
        [Key]
        public int Id { get; set; }
        [DisplayName("Edited By")]
        public string EditorId { get; set; }

        [ForeignKey("EditorId")]
        public virtual ApplicationUser User { get; set; }

        public int ContratId { get; set; }

        [ForeignKey("ContractId")]
        public virtual Contract Contrat { get; set; }

        [StringLength(2, MinimumLength = 255)]
        public string ChangeReason { get; set; }

        [Required]
        [DataType(DataType.Date)]
        public DateTime DateEdited { get; set; }

    }

This seems to work fine in logging who made changes to a contract but I want to "store" the previous version of the contract when the contract is updated so users will be able to look up what changes were made. How can I achieve that?



from Recent Questions - Stack Overflow https://ift.tt/2O5A6y3
https://ift.tt/eA8V8J

Comments

Popular posts from this blog

Today Walkin 14th-Sept

Hibernate Search - Elasticsearch with JSON manipulation

Spring Elasticsearch Operations