Exemplo n.º 1
0
        public ActionResult Create([Bind(Include = "Name,BotId")] IntentionCreateModel intention)
        {
            if (this.ModelState.IsValid)
            {
                var id = this._intentionService.RegisterIntention(intention, this.User.Identity.Name);

                return(RedirectToAction("Details", new { id = id }));
            }

            return(View(intention));
        }
        public long RegisterIntention(IntentionCreateModel model, string createdBy)
        {
            var bot = this.FindBotById(model.BotId);

            var intention = new Intention()
            {
                CreatedBy = createdBy,
                Name      = model.Name,
                BotId     = bot.Id,
                Bot       = bot
            };

            this.Data.IntentionRepository.Add(intention);
            this.Data.SaveChanges();

            return(intention.Id);
        }