public void GenerateSecretCodeTest_IsGenerating_ShouldIsNotNull()
 {
     //arrange
     Secret_code scr = new Secret_code();
     //act
     scr.GenerateCode();
     //assert
     Assert.IsNotNull(scr.secret_code);
 }
        public ActionResult SecretCode(char action = '0', int id_secret_code = -1)
        {
            switch (action)
            {
                case 'a':
                    Secret_code secret_code = new Secret_code();
                    secret_code.GenerateCode();

                    try
                    {
                        while (DB.Secret_code.Count(sc => sc.secret_code == secret_code.secret_code) > 0)
                            secret_code.GenerateCode();

                        DB.Secret_code.Add(secret_code);
                        DB.SaveChanges();
                    }
                    catch (Exception)
                    {
                        ModelState.AddModelError("-1", Localizator.Localizate("Error_creating_secret_code", CurrentLangCode)); //Ошибка при добавлении секретного кода
                    }
                    break;

                case 'r':
                    try
                    {
                        if (DB.Secret_code.Count(sc => sc.id_secret_code == id_secret_code) > 0)
                        {
                            DB.Secret_code.Remove(DB.Secret_code.Find(id_secret_code));
                            DB.SaveChanges();
                        }
                        else
                        {
                            ModelState.AddModelError("-2", Localizator.Localizate("Error_remove_secret_code", CurrentLangCode));
                        }                        
                    }
                    catch (Exception)
                    {
                        ModelState.AddModelError("-2", Localizator.Localizate("Error_remove_secret_code", CurrentLangCode));
                    }
                    break;
            }

            ViewBag.secret_codes = DB.Secret_code.ToList();

            return View();
        }