Beispiel #1
0
 // To protect from overposting attacks, enable the specific properties you want to bind to.
 // For more details, see https://aka.ms/RazorPagesCRUD.
 public async Task <IActionResult> OnPostAsync()
 {
     if (!ModelState.IsValid)
     {
         return(Page());
     }
     // update date is current time
     Blog.update_date            = DateTime.Now;
     _context.Attach(Blog).State = EntityState.Modified;
     try
     {
         await _context.SaveChangesAsync();
     }
     catch (DbUpdateConcurrencyException)
     {
         if (!BlogExists(Blog.id))
         {
             return(NotFound());
         }
         else
         {
             throw;
         }
     }
     return(RedirectToPage("./Index"));
 }
Beispiel #2
0
        // To protect from overposting attacks, see https://aka.ms/RazorPagesCRUD
        public async Task <IActionResult> OnPostAsync()
        {
            if (!ModelState.IsValid)
            {
                return(Page());
            }
            // release date and update date is current time
            Blog.release_date = DateTime.Now;
            Blog.update_date  = DateTime.Now;
            _context.Blog.Add(Blog);
            await _context.SaveChangesAsync();

            _logger.QuoteAdd(Blog.title);
            return(RedirectToPage("./Index"));
        }
Beispiel #3
0
        public async Task <IActionResult> OnPostAsync(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            Blog = await _context.Blog.FindAsync(id);

            if (Blog != null)
            {
                _context.Blog.Remove(Blog);
                await _context.SaveChangesAsync();

                _logger.QuoteDelete(Blog.ToString(), (int)id);
            }

            return(RedirectToPage("./Index"));
        }