示例#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(GlucoseEntry).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!GlucoseEntryExists(GlucoseEntry.Id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(RedirectToPage("./Index"));
        }
        // 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()
        {
            ExerciseEntry.Username = User.Identity.Name;
            ExerciseEntry.Date     = DateTime.Now;

            /*if (!ModelState.IsValid)
             * {
             *  return Page();
             * }*/

            _context.ExerciseEntry.Add(ExerciseEntry);
            await _context.SaveChangesAsync();

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

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

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

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