Пример #1
0
        public ActionResult Create(Activity activity)
        {
            if (ModelState.IsValid)
            {
                db.Activities.Add(activity);
                db.SaveChanges();
                return RedirectToAction("Index");
            }

            return View(activity);
        }
Пример #2
0
        public void SaveActivity(Activity activity)
        {
            if (activity.ActivityId == 0)
            {
                _context.Activities.Add(activity);
            }
            else
            {
                _context.Activities.Attach(activity);
                _context.Entry<Activity>(activity).State = System.Data.EntityState.Modified;
            }

            _context.SaveChanges();
        }
Пример #3
0
 public ActionResult Edit(Activity activity)
 {
     if (ModelState.IsValid)
     {
         db.Entry(activity).State = EntityState.Modified;
         db.SaveChanges();
         return RedirectToAction("Index");
     }
     return View(activity);
 }