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

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

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

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

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

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

            return(RedirectToPage("./Index"));
        }
Ejemplo n.º 3
0
        public async Task <IActionResult> OnPostAsync()
        {
            if (!ModelState.IsValid)
            {
                return(Page());
            }

            ClaimsPrincipal currentUser   = this.User;
            var             currentUserID = currentUser.FindFirst(ClaimTypes.NameIdentifier).Value;

            Tracker.OwnerID = currentUserID;


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

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