예제 #1
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,Source,Url")] WhiteListModel whiteListModel)
        {
            if (id != whiteListModel.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    whiteListModel.Modified = DateTime.UtcNow;

                    _context.Update(whiteListModel);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!WhiteListModelExists(whiteListModel.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(whiteListModel));
        }
예제 #2
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,User,Groups")] AdminModel adminModel)
        {
            if (id != adminModel.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(adminModel);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!AdminModelExists(adminModel.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(adminModel));
        }
        public async Task <IActionResult> Edit(int id, [Bind("Id,Title,Created,Modified,Active,UrlHash,User,Address,ShortAddress")] UrlViewModel urlViewModel)
        {
            if (id != urlViewModel.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    urlViewModel.Modified = DateTime.UtcNow;

                    if (urlViewModel.Active == false)
                    {
                        await _cache.Remove(urlViewModel.ShortAddress);
                    }

                    _context.Update(urlViewModel);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!UrlViewModelExists(urlViewModel.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(urlViewModel));
        }