コード例 #1
0
        public IActionResult OnPost(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            Quote = repository.GetQuoteById(id.Value);

            if (Quote != null)
            {
                repository.Delete(Quote.Id);
            }
            repository.Commit();
            return(RedirectToPage("./Index"));
        }
コード例 #2
0
        public IActionResult OnPost()
        {
            if (!ModelState.IsValid)
            {
                return(Page());
            }

            if (Quote.Id == 0)
            {
                Quote = repository.Create(Quote);
            }

            repository.Commit();
            var list = samurairepo.GetSamurais().ToList().Select(x => new { Id = x.Id, SamuraiName = $"{x.Name}" });

            Samurais = new SelectList(list, "Id", "SamuraiName");
            return(RedirectToPage("./Index"));
        }