Example #1
0
        // To protect from overposting attacks, please 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());
            }

            _context.Attach(Article).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!ArticleExists(Article.ID))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(RedirectToPage("./Index"));
        }
Example #2
0
        public async Task <IActionResult> OnPostAsync(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

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

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

            return(RedirectToPage("./Index"));
        }
Example #3
0
        public async Task<IActionResult> OnPostAsync(int? id)
        {
            base.GetCookie();
            if (id == null)
            {
                return NotFound();
            }

            user = await _context.User.FindAsync(id);

            if (User != null)
            {
                _context.User.Remove(user);
                await _context.SaveChangesAsync();
            }

            return RedirectToPage("./Index");
        }
Example #4
0
        // To protect from overposting attacks, please enable the specific properties you want to bind to, for
        // more details see https://aka.ms/RazorPagesCRUD.
        public async Task <IActionResult> OnPostAsync()
        {
            base.GetCookie();
            if (user.UserName == null)
            {
                ModelState.AddModelError("User.UserName", "* 用户名是必填的");
                return(Page());
            }
            if (user.Password == null)
            {
                ModelState.AddModelError("User.Password", "* 密码是必填的");
                return(Page());
            }
            _context.User.Add(user);
            await _context.SaveChangesAsync();

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