Example #1
0
 public ActionResult Edit(IntentEditViewModel model)
 {
     using (AlexaSkillEntities db = new AlexaSkillEntities())
     {
         Intent intent = db.Intents.FirstOrDefault(x => x.Id == model.IntentId);
         if (intent != null)
         {
             intent.Name             = model.Name;
             intent.ShouldEndSession = model.ShouldEndSession;
         }
         db.SaveChanges();
         return(RedirectToAction("Intents", "Skill", new { id = intent.SkillId }));
     }
 }
Example #2
0
        public ActionResult Edit(int id)
        {
            IntentEditViewModel model = new IntentEditViewModel();

            using (AlexaSkillEntities db = new AlexaSkillEntities())
            {
                Intent intent = db.Intents.FirstOrDefault(x => x.Id == id);
                if (intent != null)
                {
                    model.IntentId         = intent.Id;
                    model.Name             = intent.Name;
                    model.SkillId          = intent.SkillId;
                    model.ShouldEndSession = intent.ShouldEndSession;
                }
            }



            return(View(model));
        }
        public IntentEditViewModel GetEditViewModel(int intentId)
        {
            Intent intent = this.FirstOrDefault(q => q.Id == intentId && q.Active == true);

            if (intent != null)
            {
                IntentEditViewModel model = new IntentEditViewModel();
                model.Id          = intent.Id;
                model.Name        = intent.Name;
                model.AllPatterns = new PatternService().GetAllForEditingIntent(intentId);
                foreach (var pattern in model.AllPatterns)
                {
                    if (pattern.IntentId == intent.Id)
                    {
                        model.SelectedPatterns.Add(pattern.Id, pattern.Group);
                    }
                }
                return(model);
            }
            return(null);
        }