public ActionResult Create([Bind(Prefix = "")] Models.DonationType model)
        {
            if (ModelState.IsValid)
            {
                var db = new CodeFirst.CodeFirst();
                if (db.Donation_Type.Count() > 0)
                {
                    var item = db.Donation_Type.OrderByDescending(a => a.TypeID).FirstOrDefault();

                    db.Donation_Type.Add(new CodeFirst.Donation_Type
                    {
                        TypeID   = item.TypeID + 1,
                        TypeName = model.TypeName
                    });
                }
                else
                {
                    db.Donation_Type.Add(new CodeFirst.Donation_Type
                    {
                        TypeID   = 1,
                        TypeName = model.TypeName
                    });
                }

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

            return(View("Index", model));
        }
        public ActionResult Index(Models.DonationType model)
        {
            CodeFirst.CodeFirst db = new CodeFirst.CodeFirst();
            if (ModelState.IsValid)
            {
                var myType = db.Donation_Type.Where(i => i.TypeID == model.TypeID).FirstOrDefault();

                model.TypeID   = myType.TypeID;
                model.TypeName = myType.TypeName;
            }

            return(View(model));
        }
Exemple #3
0
        // GET: DonationTypeDetails
        public ActionResult Index(string typeID)
        {
            Models.DonationType myModel = new Models.DonationType();
            CodeFirst.CodeFirst db      = new CodeFirst.CodeFirst();
            if (typeID != null)
            {
                var intTypeID = Int32.Parse(typeID);
                var myType    = db.Donation_Type.Where(i => i.TypeID == intTypeID).FirstOrDefault();

                myModel.TypeID   = myType.TypeID;
                myModel.TypeName = myType.TypeName;
            }

            return(View(myModel));
        }
        public ActionResult Update([Bind(Prefix = "")] Models.DonationType model)
        {
            if (ModelState.IsValid)
            {
                var db   = new CodeFirst.CodeFirst();
                var type = db.Donation_Type.Where(v => v.TypeID == model.TypeID).SingleOrDefault();

                if (type != null)
                {
                    type.TypeID   = model.TypeID;
                    type.TypeName = model.TypeName;
                    db.SaveChanges();
                }

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

            return(View("Index", model));
        }
        // GET: AddDonationType
        public ActionResult Index()
        {
            var type = new Models.DonationType();

            return(View(type));
        }