Example #1
0
        public ActionResult Update(SettingSocial settingSocial)
        {
            SettingSocial SettingSocial = db.SettingSocials.Find(settingSocial.Id);

            if (settingSocial.SettingId < 1)
            {
                ModelState.AddModelError("", "setting is required");
                ViewBag.Settings = db.Settings.ToList();
                return(View(settingSocial));
            }
            if (ModelState.IsValid)
            {
                SettingSocial.Name      = settingSocial.Name;
                SettingSocial.Icon      = settingSocial.Icon;
                SettingSocial.Link      = settingSocial.Link;
                SettingSocial.SettingId = settingSocial.SettingId;

                db.Entry(SettingSocial).State = EntityState.Modified;
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.Settings = db.Settings.ToList();
            return(View(SettingSocial));
        }
Example #2
0
        public ActionResult Update(int id)
        {
            SettingSocial settingSocial = db.SettingSocials.Find(id);

            if (settingSocial == null)
            {
                return(HttpNotFound());
            }
            ViewBag.Settings = db.Settings.ToList();
            return(View(settingSocial));
        }
Example #3
0
        public ActionResult Delete(int id)
        {
            SettingSocial settingSocial = db.SettingSocials.Find(id);

            if (settingSocial == null)
            {
                return(HttpNotFound());
            }
            db.SettingSocials.Remove(settingSocial);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Example #4
0
        public ActionResult Create(SettingSocial settingSocial)
        {
            if (settingSocial.SettingId < 1)
            {
                ModelState.AddModelError("", "setting is required");
                ViewBag.Settings = db.Settings.ToList();
                return(View(settingSocial));
            }
            if (ModelState.IsValid)
            {
                db.SettingSocials.Add(settingSocial);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.Settings = db.Settings.ToList();
            return(View(settingSocial));
        }