Exemplo n.º 1
0
        public bool UpdateBoard(BoardEdit model)
        {
            using (var ctx = new ApplicationDbContext())
            {
                var entity =
                    ctx
                    .Boards
                    .Single(e => e.BoardId == model.BoardId);



                return(ctx.SaveChanges() == 1);
            }
        }
Exemplo n.º 2
0
        public ActionResult Edit(int id)
        {
            var service = CreateBoardService();
            var detail  = service.GetBoardById(id);
            var model   =
                new BoardEdit
            {
                BoardId     = detail.BoardId,
                Name        = detail.Name,
                Description = detail.Description
            };

            return(View(model));
        }
Exemplo n.º 3
0
        public ActionResult Edit(int id)
        {
            var service = CreateBoardService();
            var detail  = service.GetBoardById(id);
            var model   =
                new BoardEdit
            {
                BoardId       = detail.BoardId,
                BoardCategory = detail.BoardCategory,
                BoardName     = detail.BoardName,
                Description   = detail.Description,
                Price         = detail.Price,
                BoardQuality  = detail.BoardQuality
            };

            return(View(model));
        }
Exemplo n.º 4
0
        public bool UpdateBoard(BoardEdit model)
        {
            using (var ctx = new ApplicationDbContext())
            {
                var entity =
                    ctx
                    .Boards
                    .Single(e => e.BoardId == model.BoardId);

                entity.BoardCategory = model.BoardCategory;
                entity.BoardName     = model.BoardName;
                entity.Description   = model.Description;
                entity.Price         = model.Price;
                entity.BoardQuality  = model.BoardQuality;

                return(ctx.SaveChanges() == 1);
            }
        }
Exemplo n.º 5
0
        public ActionResult Edit(int id, BoardEdit model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            if (model.BoardId != id)
            {
                ModelState.AddModelError("", "Id Mismatch");
                return(View(model));
            }

            var service = CreateBoardService();

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

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