Beispiel #1
0
        public bool UpdateThread(ThreadEdit model)
        {
            var entity = _dbContext.Threads
                         .Single(x => x.ThreadID == model.ThreadID);

            entity.ThreadTitle       = model.ThreadTitle;
            entity.ThreadDescription = model.ThreadDescription;

            return(_dbContext.SaveChanges() == 1);
        }
Beispiel #2
0
        // GET: /Thread/MyThreadsEdit/{id}
        public ActionResult MyThreadsEdit(int id)
        {
            var service = CreateThreadService();
            var detail  = service.GetThreadByID(id);
            var model   = new ThreadEdit
            {
                ThreadID          = detail.ThreadID,
                ThreadTitle       = detail.ThreadTitle,
                ThreadDescription = detail.ThreadDescription
            };

            return(View(model));
        }
Beispiel #3
0
        public bool UpdateThread(ThreadEdit model)
        {
            using (var ctx = new ApplicationDbContext())
            {
                var entity =
                    ctx
                    .Threads
                    .Single(e => e.ThreadID == model.ThreadID);

                entity.Title = model.Title;
                return(ctx.SaveChanges() == 1);
            }
        }
        public ActionResult Edit(Guid id)
        {
            var service = CreateThreadService();
            var detail  = service.GetThreadById(id);
            var model   =
                new ThreadEdit
            {
                ThreadID = detail.ThreadID,
                Title    = detail.Title
            };

            return(View(model));
        }
        public ActionResult Edit(int threadID)
        {
            var service = CreateThreadService();
            var detail  = service.GetThreadByID(threadID);
            var model   = new ThreadEdit
            {
                ThreadID          = detail.ThreadID,
                ThreadTitle       = detail.ThreadTitle,
                ThreadDescription = detail.ThreadDescription
            };

            if (service.ValidateUser(threadID) == true)
            {
                return(View(model));
            }

            return(View("ValidationFailed"));
        }
        public ActionResult Edit(int threadID, ThreadEdit model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            if (model.ThreadID != threadID)
            {
                ModelState.AddModelError("", "ID Mismatch");
                return(View(model));
            }

            var service = CreateThreadService();

            if (service.UpdateThread(model))
            {
                TempData["SaveResult"] = "Your thread was updated.";
                return(RedirectToAction("Index"));
            }

            ModelState.AddModelError("", "Your thread could not be updated.");
            return(View(model));
        }