Exemple #1
0
        /// <summary>
        /// This method to perform the disable or enable the record
        /// </summary>
        /// <param name="appId">based on app id</param>
        /// <returns></returns>
        public async Task <ActionResult> IsEnableOrDisable(int appId)
        {
            try
            {
                using (var db = new ApplicationDbContext())
                {
                    TokenGenerationService token = new TokenGenerationService(_db, _mapper);

                    var tokenRecord = await token.setDisabledByAppId(appId);

                    if (tokenRecord.IsDisabled == true)
                    {
                        tokenRecord.IsDisabled = false;
                    }
                    else
                    {
                        tokenRecord.IsDisabled = true;
                    }
                    _db.Entry(tokenRecord).State = EntityState.Modified;
                    _db.SaveChanges();
                    return(RedirectToAction("Index"));
                }
            }
            catch (Exception ex)
            {
                return(View("Error"));
            }
        }
Exemple #2
0
        public async Task <ActionResult> UpdateToken(int appId)
        {
            using (var db = new ApplicationDbContext())
            {
                TokenGenerationService token = new TokenGenerationService(db, _mapper);
                var result = await token.getAppDetailsByAppId(appId);

                return(PartialView(result));
            }
        }
Exemple #3
0
 public AuthenticationController(
     IUsuarioService usuarioService,
     UsuarioValidator validator,
     TokenGenerationService tokenGenerator,
     KeyHasherService keyHasherService,
     IConfiguration config)
 {
     _usuarioService   = usuarioService;
     _validator        = validator;
     _tokenGenerator   = tokenGenerator;
     _keyHasherService = keyHasherService;
     _config           = config;
 }
Exemple #4
0
        /// <summary>
        /// Method to get the all apps Log history
        /// </summary>
        /// <returns>returns all app log history</returns>


        public async Task <ActionResult> AllAppHistory()
        {
            try
            {
                using (var db = new ApplicationDbContext())
                {
                    TokenGenerationService token = new TokenGenerationService(_db, _mapper);
                    var historydetails           = await token.GetAllAppsHistory();

                    return(View(historydetails));
                }
            }
            catch (Exception ex)
            {
                return(View("Error"));
            }
        }
Exemple #5
0
        public async Task <ActionResult> UpdateToken(AppDetails details)
        {
            try
            {
                using (var db = new ApplicationDbContext())
                {
                    TokenGenerationService token = new TokenGenerationService(db, _mapper);
                    var record = await token.UpdateDetails(details);

                    TempData["UpdateTokenSuccess"] = "Token Updated Successfully!";
                    return(RedirectToAction("Index"));
                }
            }
            catch (Exception ex)
            {
                TempData["UpdateTokenFailure"] = "Token Updated Successfully!";
                return(RedirectToAction("Index"));
            }
        }
Exemple #6
0
        public async Task <ActionResult> GenerateNewToken(AppDetails det)
        {
            try
            {
                using (var db = new ApplicationDbContext())
                {
                    if (ModelState.IsValid)
                    {
                        TokenGenerationService token = new TokenGenerationService(_db, _mapper);
                        var tokenExits = token.ValidateToken(det.TokenId);
                        if (tokenExits == null)
                        {
                            var dateNow = DateTime.UtcNow;
                            await token.Create(new UserTokenDetails
                            {
                                DateCreated = dateNow,
                                AppName     = det.AppName,
                                UserName    = det.UserName,
                                TokenId     = det.TokenId,
                                IsDisabled  = true
                            });

                            TempData["CreateCompleteMessage"] = "Token Created Successfully";
                        }
                        else
                        {
                            TempData["tokenExits"] = "Token Already Exists";
                            return(RedirectToAction("Index"));
                        }
                    }
                    return(RedirectToAction("Index"));
                }
            }
            catch (Exception ex)
            {
                return(View("Error"));
            }
        }