Example #1
0
        public async Task <IActionResult> OnPostAsync()
        {
            if (!ModelState.IsValid)
            {
                return(Page());
            }

            _db.Quotes.Add(Quotes);

            await _db.SaveChangesAsync();

            QuoteImage.Create(Quotes, "Helvetica", 40, 780f);

            return(RedirectToPage("/Quote", new { id = Quotes.Id }));
        }
Example #2
0
        public async Task <IActionResult> OnPostAsync()
        {
            if (!ModelState.IsValid)
            {
                return(Page());
            }

            _db.Attach(Quotes).State = EntityState.Modified;

            try
            {
                await _db.SaveChangesAsync();

                QuoteImage.Create(Quotes, "Helvetica", 40, 780f);
            }
            catch (DbUpdateConcurrencyException e)
            {
                throw new Exception($"Quote {Quotes.Id} not found!", e);
            }

            return(RedirectToPage("/QuotesList"));
        }