コード例 #1
0
ファイル: BotServices.cs プロジェクト: jaeduh/WeKnowBotsFinal
        public bool CreateBot(BotCreate model)
        {
            var entity = new Bot()
            {
                BotId       = model.BotId,
                BotName     = model.BotName,
                TypeOfBot   = model.TypeOfBot,
                DateBotUsed = model.DateBotUsed
            };

            using (var ctx = new ApplicationDbContext())
            {
                ctx.Bots.Add(entity);
                return(ctx.SaveChanges() == 1);
            }
        }
コード例 #2
0
        public ActionResult Create(BotCreate model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            var service = CreateBotService();

            if (service.CreateBot(model))
            {
                ViewBag.SaveResult = "Your bot has been created.";
                return(RedirectToAction("Index"));
            }
            ;

            ModelState.AddModelError("", "Your could not be created.");

            return(View(model));
        }