Example #1
0
        public void SaveTheme(Theme theme)
        {
            if (theme.Id == 0)
            {
                db.Theme.Add(theme);
            }
            else
            {

                Theme dbEntry = db.Theme.Find(theme.Id);
                if (dbEntry != null)
                {

                    dbEntry.Name = theme.Name;
                }
            }

            db.SaveChanges();
        }
Example #2
0
 public ActionResult EditTheme(Theme theme)
 {
     if (ModelState.IsValid)
     {
         SaveTheme(theme);
         TempData["message"] = string.Format("{0} has been saved", theme.Name);
         return RedirectToAction("Index");
     }
     else
     {
         // there is something wrong with the data values
         return View(theme);
     }
 }