Example #1
0
        public async Task <IActionResult> Edit(int id, [Bind("ID,Name,Password")] User user)
        {
            if (id != user.ID)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    user.Password = HashString(user.Password);
                    _context.Update(user);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!UserExists(user.Name))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(user));
        }
Example #2
0
        public async Task <IActionResult> Create(RegexForm data)
        {
            if (data != null)
            {
                Regex regex = new Regex();
                regex.Name        = data.Name;
                regex.Description = data.Description;
                regex.Value       = this.Builder(data);
                _context.Add(regex);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            else
            {
                return(View(data));
            }
        }
Example #3
0
 public async Task <int> SaveAsync()
 {
     try
     {
         return(await _context.SaveChangesAsync());
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }