public IActionResult Category(CategoryViewModel categoryViewModel) { _context.Categories.Add(categoryViewModel.Category); _context.SaveChanges(); categoryViewModel.Categories = _context.Categories.ToList(); return(View(categoryViewModel)); }
public IActionResult GetKey() { var user = User.Identity.Name; if (_context.UserKeys.Find(user) == null) { var currentTime = DateTime.Now; var notHashedKey = user + new Random().Next() + currentTime; var key = HashService.GetHashString(notHashedKey); _context.UserKeys.Add(new UserKey { Key = key, Username = user }); _context.SaveChanges(); } return(RedirectToAction("GetApiKey")); }