예제 #1
0
 public IActionResult Category(CategoryViewModel categoryViewModel)
 {
     _context.Categories.Add(categoryViewModel.Category);
     _context.SaveChanges();
     categoryViewModel.Categories = _context.Categories.ToList();
     return(View(categoryViewModel));
 }
예제 #2
0
        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"));
        }