Ejemplo n.º 1
0
        public ActionResult DeleteConfirmed(int id)
        {
            ListOfType listOfType = db.ListOfTypes.Find(id);

            listOfType.Hide = true;
            db.ListOfTypes.Remove(listOfType);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Ejemplo n.º 2
0
 public ActionResult Edit([Bind(Include = "ID,Type,Hide")] ListOfType listOfType)
 {
     if (ModelState.IsValid)
     {
         db.Entry(listOfType).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(listOfType));
 }
Ejemplo n.º 3
0
        // GET: ListOfTypes/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            ListOfType listOfType = db.ListOfTypes.Find(id);

            if (listOfType == null)
            {
                return(HttpNotFound());
            }
            return(View(listOfType));
        }
Ejemplo n.º 4
0
        public ActionResult Create([Bind(Include = "ID,Type")] ListOfType listOfType)
        {
            if (ModelState.IsValid)
            {
                foreach (var type in listOfType.Type.Split(','))
                {
                    bool FoundType = db.ListOfTypes.Where(m => m.Type.Contains(listOfType.Type)).Count() > 0;
                    if (!FoundType)
                    {
                        db.ListOfTypes.Add(new ListOfType()
                        {
                            Type = type
                        });
                        db.SaveChanges();
                    }
                }


                return(RedirectToAction("Index"));
            }

            return(View(listOfType));
        }