Exemple #1
0
        public bool CreateBoard(BoardCreate model)
        {
            var entity =
                new Board()
            {
                BoardName     = model.BoardName,
                Description   = model.Description,
                Price         = model.Price,
                BoardCategory = model.BoardCategory,
            };

            using (var ctx = new ApplicationDbContext())
            {
                ctx.Boards.Add(entity);
                return(ctx.SaveChanges() == 1);
            }
        }
Exemple #2
0
        public ActionResult Create(BoardCreate model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            var service = CreateBoardService();

            if (service.CreateBoard(model))
            {
                TempData["SaveResult"] = "Your board was posted.";
                return(RedirectToAction("Index"));
            }
            ;

            ModelState.AddModelError("", "Board could not be posted.");

            return(View(model));
        }