title: Handling Created and Modified Date in MVC
body: <p>HI i have an MVC application which have CreatedDate and ModifiedDate feilds, 
  1. CreatedDate is when user create the module(any entry)
  2. ModifiedDate is when user Edit the module</p>
  
  <p>I have following Model class</p>
  
  <pre><code>namespace MyForms.Models
  {
      public class Master
      {
          public int ID { get; set; }
          public string ModuleName { get; set; }
          public int CreatedBy { get; set; }
          public DateTime ? CreatedDate { get; set; }
          public int ModifyBy { get; set; }
          public DateTime ModifyDate { get; set; }
          public Boolean IsActive { get; set; }
          public Boolean IsDeleted { get; set; }
  
           // public virtual ICollection&lt;Master&gt; MasterModules { get; set; }
      }
      public class MyFormDemoContext : DbContext
      {
          public DbSet&lt;Master&gt; MasterForms { get; set;}
      }
      }
  </code></pre>
  
  <p>Actions of Create and Edit</p>
  
  <pre><code>public ActionResult Create()
          {
              return View();
          }
          [HttpPost]
          public ActionResult Create(Master master)
          {
              try
              {
                  using (MyFormDemoContext context = new MyFormDemoContext()) 
                  {
                      master.CreatedBy = 1;
                      master.CreatedDate = DateTime.Now;
                      var a = master.CreatedDate;
                      master.IsActive = true;
                      master.ModifyBy = 1;
                      master.ModifyDate = DateTime.Now;
                      master.IsDeleted = false;   
                      context.MasterForms.Add(master);
                      context.SaveChanges();
                  }
                  return RedirectToAction("Index");
              }
              catch
              {
                  return View();
              }
          }
          public ActionResult Edit(int id)
          {
              using (MyFormDemoContext context = new MyFormDemoContext())
              {
                  return View(context.MasterForms.Find(id));
              }
          }
          //
          // POST: /Home/Edit/5
          [HttpPost]
          public ActionResult Edit(int id, Master valpara)
          {
              try
              {
                  using (MyFormDemoContext context = new MyFormDemoContext())
                  {
                      valpara.CreatedBy = 1;
                      valpara.CreatedDate = DateTime.Now;
                      valpara.IsActive = true;
                      valpara.ModifyBy = 1;
                      valpara.ModifyDate = DateTime.Now;
                      valpara.IsDeleted = false;
                      valpara.ModifyDate = DateTime.Now;
                      context.Entry(valpara).State = System.Data.EntityState.Modified;
                      context.SaveChanges();
                  }
                  return RedirectToAction("Index");
              }
              catch
              {
                  return View();
  </code></pre>
  
  <p>}                }</p>
  
  <p>1.currently when i create the module(entry) createdDate goes as current date
  2. When i edit the module, modifiedDate and createdDate goes same</p>
  
  <p><strong>My expections</strong></p>
  
  <p>I want the createdDate Remains same when i Modify or edit the entry only modified date will be updated</p>