コード例 #1
0
        public ActionResult Create(StatusTypeVM v)
        {
            if (ModelState.IsValid)
            {
                tblStatusType d = new tblStatusType();

                int max = (from c in db.tblStatusTypes orderby c.ID descending select c.ID).FirstOrDefault();

                if (max == null)
                {
                    d.ID   = 1;
                    d.Name = v.Name;
                    d.Code = v.Code;
                }
                else
                {
                    d.ID   = max + 1;
                    d.Name = v.Name;
                    d.Code = v.Code;
                }



                db.tblStatusTypes.Add(d);
                db.SaveChanges();
                TempData["SuccessMsg"] = "You have successfully added Status Type.";
                return(RedirectToAction("Index"));
            }
            return(View());
        }
コード例 #2
0
        public ActionResult Details(int id)
        {
            tblStatusType tblstatustype = db.tblStatusTypes.Find(id);

            if (tblstatustype == null)
            {
                return(HttpNotFound());
            }
            return(View(tblstatustype));
        }
コード例 #3
0
        public ActionResult DeleteConfirmed(int id)
        {
            tblStatusType statustype = db.tblStatusTypes.Find(id);

            if (statustype == null)
            {
                return(HttpNotFound());
            }
            else
            {
                db.tblStatusTypes.Remove(statustype);
                db.SaveChanges();
                TempData["SuccessMsg"] = "You have successfully Deleted Status Type.";
                return(RedirectToAction("Index"));
            }
        }
コード例 #4
0
        public ActionResult Edit(StatusTypeVM v)
        {
            if (ModelState.IsValid)
            {
                tblStatusType c = new tblStatusType();
                c.ID   = v.ID;
                c.Name = v.Name;
                c.Code = v.Code;

                db.Entry(c).State = EntityState.Modified;
                db.SaveChanges();
                TempData["SuccessMsg"] = "You have successfully updated Status Type.";
                return(RedirectToAction("Index"));
            }
            return(View());
        }