Example #1
0
        public ActionResult DeleteConfirmed(int id)
        {
            ArbolClases arbolClases = db.ArbolClases.Find(id);

            db.ArbolClases.Remove(arbolClases);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Example #2
0
 public ActionResult Edit([Bind(Include = "IDClase,Clase,HPMax,FuerzaMax,MagiaMax,HabMax,VelMax,SuerMax,DefMax,ResMax")] ArbolClases arbolClases)
 {
     if (ModelState.IsValid)
     {
         db.Entry(arbolClases).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(arbolClases));
 }
Example #3
0
        // GET: ArbolClases/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            ArbolClases arbolClases = db.ArbolClases.Find(id);

            if (arbolClases == null)
            {
                return(HttpNotFound());
            }
            return(View(arbolClases));
        }
Example #4
0
        public ActionResult Create(FormCollection CrearUnidad)
        {
            try
            {
                ArbolClases NewClass = new ArbolClases();
                NewClass.Clase = CrearUnidad["Clase"].ToString();
                Boolean tempVal = CrearUnidad["Promocion"] != null ? true : false;
                TempData["Promocion"] = tempVal;
                NewClass.Promocion    = tempVal;
                NewClass.HPMax        = int.Parse(CrearUnidad["HPMax"].ToString());
                NewClass.FuerzaMax    = int.Parse(CrearUnidad["FuerzaMax"].ToString());
                NewClass.MagiaMax     = int.Parse(CrearUnidad["MagiaMax"].ToString());
                NewClass.HabMax       = int.Parse(CrearUnidad["HabMax"].ToString());
                NewClass.VelMax       = int.Parse(CrearUnidad["VelMax"].ToString());
                NewClass.SuerMax      = int.Parse(CrearUnidad["SuerMax"].ToString());
                NewClass.DefMax       = int.Parse(CrearUnidad["DefMax"].ToString());
                NewClass.ResMax       = int.Parse(CrearUnidad["ResMax"].ToString());
                db.ArbolClases.Add(NewClass);
                db.SaveChanges();
            }
            catch (DbEntityValidationException e)
            {
                foreach (var eve in e.EntityValidationErrors)
                {
                    ViewBag.MiMensaje = "Entity of type \"{0}\" in state \"{1}\" has the following validation errors:" + "-" + "-" + eve.Entry.Entity.GetType().Name + "-" + eve.Entry.State;
                    var msj = eve.Entry.Entity.GetType().Name + " " + eve.Entry.State;

                    ViewBag.MiMensaje0 = msj.ToString();

                    foreach (var ve in eve.ValidationErrors)
                    {
                        ViewBag.MiMensaje1 = "- Property: \"{0}\", Value: \"{1}\", Error: \"{2}\"" + "-" + ve.PropertyName + " " + eve.Entry.CurrentValues.GetValue <object>(ve.PropertyName) + " " + ve.ErrorMessage;
                    }
                }
                throw;
            }
            return(RedirectToAction("Index"));
        }