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); } }
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)); }