コード例 #1
0
        public ActionResult Edit(int id, FormCollection collection)
        {
            try
            {
                var model = new AdHocPageModel();

                UpdateModel(model);

                using (var repo = new AdHocPageRepository())
                {
                    var entity = repo.GetById(model.Id);

                    entity.Url  = model.Url;
                    entity.User = UserIdentity.GetShortName(User);
                    entity.Test = model.Test;

                    repo.SaveChanges();
                }

                return(RedirectToAction("Index"));
            }
            catch
            {
                return(View());
            }
        }
コード例 #2
0
        // GET: PageAdmin/Edit/5
        public ActionResult Edit(short id)
        {
            var model = new AdHocPageModel();

            using (var repo = new AdHocPageRepository())
            {
                var entity = repo.GetById(id);

                model.Id   = id;
                model.Url  = entity.Url;
                model.Test = entity.Test;
            }

            return(View(model));
        }
コード例 #3
0
        // GET: PageAdmin/Delete/5
        public ActionResult Delete(short id)
        {
            var model = new AdHocPageModel();

            using (var repo = new AdHocPageRepository())
            {
                var entity = repo.GetById(id);

                model.Id   = id;
                model.Url  = entity.Url;
                model.Test = entity.Test;
            }

            return View(model);
        }
コード例 #4
0
        public ActionResult Delete(int id, FormCollection collection)
        {
            try
            {
                using (var repo = new AdHocPageRepository())
                {
                    var entity = repo.GetById(id);
                    repo.DbSet.Remove(entity);
                    repo.SaveChanges();
                }

                return(RedirectToAction("Index"));
            }
            catch
            {
                return(View());
            }
        }
コード例 #5
0
        public ActionResult Delete(int id, FormCollection collection)
        {
            try
            {
                using (var repo = new AdHocPageRepository())
                {
                    var entity = repo.GetById(id);
                    repo.DbSet.Remove(entity);
                    repo.SaveChanges();
                }

                return RedirectToAction("Index");
            }
            catch
            {
                return View();
            }
        }
コード例 #6
0
        public ActionResult Edit(int id, FormCollection collection)
        {
            try
            {
                var model = new AdHocPageModel();

                UpdateModel(model);

                using (var repo = new AdHocPageRepository())
                {
                    var entity = repo.GetById(model.Id);

                    entity.Url    = model.Url;
                    entity.User   = UserIdentity.GetShortName(User);
                    entity.Test   = model.Test;

                    repo.SaveChanges();
                }

                return RedirectToAction("Index");
            }
            catch
            {
                return View();
            }
        }