コード例 #1
0
        public ActionResult Edit(int id)
        {
            ZoneCategory   a = (from c in db.ZoneCategories where c.ZoneCategoryID == id select c).FirstOrDefault();
            ZoneCategoryVM v = new ZoneCategoryVM();

            v.ZoneCategoryID     = a.ZoneCategoryID;
            v.ZoneCategory       = a.ZoneCategory1;
            v.StatusBaseCategory = a.StatusBaseCategory.Value;

            return(View(v));
        }
コード例 #2
0
        public ActionResult Create(ZoneCategoryVM v)
        {
            ZoneCategory a = new ZoneCategory();

            if (ModelState.IsValid)
            {
                a.ZoneCategory1      = v.ZoneCategory;
                a.StatusBaseCategory = v.StatusBaseCategory;


                db.ZoneCategories.Add(a);
                db.SaveChanges();
                TempData["SuccessMsg"] = "You have successfully added Zone Category.";
                return(RedirectToAction("Index"));
            }
            return(View());
        }
コード例 #3
0
        public ActionResult Index()
        {
            List <ZoneCategoryVM> lst = new List <ZoneCategoryVM>();
            var data = (from c in db.ZoneCategories select c).ToList();


            foreach (var item in data)
            {
                ZoneCategoryVM v = new ZoneCategoryVM();
                v.ZoneCategoryID     = item.ZoneCategoryID;
                v.ZoneCategory       = item.ZoneCategory1;
                v.StatusBaseCategory = item.StatusBaseCategory.Value;

                lst.Add(v);
            }
            return(View(lst));
        }
コード例 #4
0
        public ActionResult Edit(ZoneCategoryVM v)
        {
            ZoneCategory a = new ZoneCategory();

            if (ModelState.IsValid)
            {
                a.ZoneCategoryID     = v.ZoneCategoryID;
                a.ZoneCategory1      = v.ZoneCategory;
                a.StatusBaseCategory = v.StatusBaseCategory;

                db.Entry(a).State = EntityState.Modified;
                db.SaveChanges();
                TempData["SuccessMsg"] = "You have successfully Updated Zone Category.";
                return(RedirectToAction("Index"));
            }

            return(View());
        }