Ejemplo n.º 1
0
        public ActionResult Create([Bind(Prefix = "")] Models.FunderType model)
        {
            var db = new CodeFirst.CodeFirst();

            if (ModelState.IsValid)
            {
                if (db.Funder_Type.Count() > 0)
                {
                    var item = db.Funder_Type.OrderByDescending(a => a.TypeID).FirstOrDefault();

                    db.Funder_Type.Add(new CodeFirst.Funder_Type
                    {
                        TypeID      = item.TypeID + 1,
                        Name        = model.Name,
                        Description = model.Description
                    });
                }
                else
                {
                    db.Funder_Type.Add(new CodeFirst.Funder_Type
                    {
                        TypeID      = 1,
                        Name        = model.Name,
                        Description = model.Description
                    });
                }

                db.SaveChanges();
                model.JavaScriptToRun = "mySuccess()";
                TempData["model"]     = model;
                return(RedirectToAction("Index", "FunderType"));
            }

            return(View("Index", model));
        }
Ejemplo n.º 2
0
        // GET: AddFunderType
        public ActionResult Index()
        {
            var db         = new CodeFirst.CodeFirst();
            var FunderType = new Models.FunderType();

            return(View(FunderType));
        }
Ejemplo n.º 3
0
 // GET: FunderType
 public ActionResult Index()
 {
     Models.FunderType myModel = new Models.FunderType();
     if (TempData["model"] != null)
     {
         myModel = (Models.FunderType)TempData["model"];
         TempData.Remove("model");
     }
     return(View(myModel));
 }
Ejemplo n.º 4
0
        // GET: FunderTypeDetails
        public ActionResult Index(string typeID)
        {
            Models.FunderType   myModel = new Models.FunderType();
            CodeFirst.CodeFirst db      = new CodeFirst.CodeFirst();
            if (typeID != null)
            {
                var intTypeID    = Int32.Parse(typeID);
                var myFunderType = db.Funder_Type.Where(i => i.TypeID == intTypeID).FirstOrDefault();

                myModel.TypeID      = myFunderType.TypeID;
                myModel.Name        = myFunderType.Name;
                myModel.Description = myFunderType.Description;
            }

            return(View(myModel));
        }
        public ActionResult Index(Models.FunderType model)
        {
            CodeFirst.CodeFirst db = new CodeFirst.CodeFirst();

            if (ModelState.IsValid)
            {
                Models.FunderType myModel = new Models.FunderType();

                var myFunderType = db.Funder_Type.Where(i => i.TypeID == model.TypeID).FirstOrDefault();

                myModel.TypeID      = myFunderType.TypeID;
                myModel.Name        = myFunderType.Name;
                myModel.Description = myFunderType.Description;

                return(View(myModel));
            }

            return(View(model));
        }
        public ActionResult Modify([Bind(Prefix = "")] Models.FunderType model)
        {
            var db = new CodeFirst.CodeFirst();

            if (ModelState.IsValid)
            {
                var FunderType = db.Funder_Type.Where(v => v.TypeID == model.TypeID).SingleOrDefault();

                if (FunderType != null)
                {
                    FunderType.TypeID      = model.TypeID;
                    FunderType.Name        = model.Name;
                    FunderType.Description = model.Description;
                    db.SaveChanges();
                }

                TempData["js"] = "myUpdateSuccess()";
                return(RedirectToAction("Index", "FunderType"));
            }

            return(View("Index", model));
        }