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

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

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!AddressExists(Address.Id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }
            return(RedirectToPage("./Index"));
        }
Ejemplo n.º 2
0
        public async Task <ActionResult> OnPostClickedAsync(int id)
        {
            Address = _context.Address.ToList();
            string url = "";

            foreach (var address in Address)
            {
                if (address.Id == id)
                {
                    url = address.LongAddress;
                    address.Clicked++;
                    _context.Attach(address).State = EntityState.Modified;
                    try
                    {
                        await _context.SaveChangesAsync();
                    }
                    catch (DbUpdateConcurrencyException)
                    {
                        throw;
                    }
                }
            }
            if (!string.IsNullOrEmpty(url))
            {
                return(Redirect(url));
            }
            else
            {
                return(NotFound());
            }
        }