public async Task<IActionResult> Save(Valediction data)
        {
            if (!ModelState.IsValid) {
                return View("Edit", data);
            }

            await speechService.SaveValedictionAsync(data);

            return RedirectToAction("Index");
        }
        public async Task<IActionResult> Edit(string valediction)
        {
            Valediction model = await speechService.GetValedictionAsync(valediction);

            if (model == null) {
                model = new Valediction
                {
                    IsNew = true
                };
            }

            return View(model);
        }
Exemple #3
0
        public async Task<Valediction> SaveValedictionAsync(Valediction data)
        {
            Valediction existing = await GetValedictionAsync(data.ValedictionString);

            if (existing == null) {
                dataContext.Valedictions.Add(data);
            } else {
                existing.Aggressiveness = data.Aggressiveness;
                dataContext.Valedictions.Update(data);
            }

            await dataContext.SaveChangesAsync();

            return existing;
        }