Ejemplo n.º 1
0
        public async Task <IActionResult> OnGetAsync(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            Mapping = await _context.Mapping.FirstOrDefaultAsync(m => m.Id == id);

            if (Mapping == null)
            {
                return(NotFound());
            }
            return(Page());
        }
Ejemplo n.º 2
0
        public async Task <IActionResult> OnGetAsync(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }
            var user = await _userManager.GetUserAsync(HttpContext.User);

            Mapping = await _context.Mapping.FirstOrDefaultAsync(m => m.Id == id && m.Owner == user);

            if (Mapping == null)
            {
                return(NotFound());
            }
            return(Page());
        }
Ejemplo n.º 3
0
        public async Task <IActionResult> OnPostAsync(long?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

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

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

            return(RedirectToPage("./Index"));
        }
Ejemplo n.º 4
0
        public async Task <IActionResult> OnPostAsync(long?id)
        {
            if (id == null)
            {
                return(NotFound());
            }
            var user = await _userManager.GetUserAsync(HttpContext.User);

            var target = _context.Mapping.Find(Mapping.Id);

            if (user != target.Owner)
            {
                return(Unauthorized());
            }
            Mapping = await _context.Mapping.FindAsync(id);

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

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