// // GET: /Category/Create public ActionResult Create() { Category category = new Category(); category.OnCreate(); return View(category); }
public ActionResult Create(Category category) { if (ModelState.IsValid) { // Add Audit Entry AuditTrail audit = new AuditTrail(DateTime.Now, User.Identity.Name, category, category.CategoryID, "Create"); db.AuditTrails.Add(audit); db.Categories.Add(category); db.SaveChanges(); return RedirectToAction("Index"); } return View(category); }
// Category public AuditTrail(DateTime dateTime, string userName, Category category, int id, string comment) { this.AuditTrailTimeStamp = dateTime; this.AuditTrailUserName = userName; this.AuditTrailComment = comment; if (id > 0) { this.CategoryID = id; } else { this.Category = category; } }