Beispiel #1
0
 public ActionResult Edit(Rules rules)
 {
     if (ModelState.IsValid)
     {
         rules.username = User.Identity.Name;
         rules.DateCreated = DateTime.Now;
         db.Entry(rules).State = EntityState.Modified;
         db.SaveChanges();
         return RedirectToAction("Index");
     }
     return View(rules);
 }
Beispiel #2
0
        public ActionResult Create(Rules rules)
        {
            if (ModelState.IsValid)
            {
                rules.DateCreated = DateTime.Now;
                rules.UserId = 1; // need to dynamic -> fill with the current user that asking to create RULE
                rules.username = User.Identity.Name;
                db.Rules.Add(rules);
                db.SaveChanges();
                return RedirectToAction("Index");
            }

            return View(rules);
        }