示例#1
0
        public ActionResult Modify_AddonCategory(AddonCatViewModel modifiedaddoncat)
        {
            var success = false;
            var message = "";

            if (!ModelState.IsValid)
            {
                return(PartialView(modifiedaddoncat));
            }

            try
            {
                var addoncat = new AddonCategory()
                {
                    addoncatId   = (int)modifiedaddoncat.addoncatId,
                    addoncatdesc = modifiedaddoncat.addoncatdetails
                };


                dbEntities.AddonCategories.Attach(addoncat);
                dbEntities.Entry(addoncat).State = EntityState.Modified;
                dbEntities.SaveChanges();

                success = true;
            }
            catch (Exception e)
            {
                message = e.Message.ToString();
                success = false;
            }

            return(Json(new { success = success }, JsonRequestBehavior.AllowGet));
        }
示例#2
0
        public ActionResult Create_AddonCategory(AddonCatViewModel newaddoncategory)
        {
            bool success = false;

            if (!ModelState.IsValid)
            {
                return(PartialView(newaddoncategory));
            }

            try
            {
                AddonCategory addoncategory = new AddonCategory()
                {
                    addoncatdesc = newaddoncategory.addoncatdetails
                };
                dbEntities.AddonCategories.Add(addoncategory);
                dbEntities.SaveChanges();

                success = true;
            }
            catch (Exception e)
            {
                var message = e.Message.ToString();

                success = false;
            }


            return(Json(new { success = success }, JsonRequestBehavior.AllowGet));
        }
示例#3
0
        public ActionResult Modify_AddonCategory(int addoncatId)
        {
            AddonCatViewModel modifyaddoncat = new AddonCatViewModel();

            if (addoncatId > 0)
            {
                var addoncat = dbEntities.AddonCategories.Find(addoncatId);

                modifyaddoncat = new AddonCatViewModel()
                {
                    addoncatId      = addoncat.addoncatId,
                    addoncatdetails = addoncat.addoncatdesc
                };
            }


            return(PartialView(modifyaddoncat));
        }