Exemple #1
0
        // GET: Languages/Delete/5
        public async Task <ActionResult> Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }

            await _languageRepository.Delete(id.Value);

            return(RedirectToAction(nameof(Index)));
        }
        public void Delete_NonExist_TmxFile_Test()
        {
            // Assign
            AbstractLanguageRepository repository = new LanguageRepository();

            // Act
            Assert.IsFalse(File.Exists(MockObjects.NonEXIST_Add_TmxFilePath.FullName));
            bool result = repository.Delete(MockObjects.NonEXIST_Add_TmxFile);

            // Assert
            Assert.IsFalse(result);
            Assert.IsFalse(File.Exists(MockObjects.NonEXIST_Add_TmxFilePath.FullName));
        }
Exemple #3
0
        public void Can_Perform_Delete_On_LanguageRepository()
        {
            // Arrange
            var provider   = new PetaPocoUnitOfWorkProvider();
            var unitOfWork = provider.GetUnitOfWork();
            var repository = new LanguageRepository(unitOfWork);

            // Act
            var language = repository.Get(3);

            repository.Delete(language);
            unitOfWork.Commit();

            var exists = repository.Exists(3);

            // Assert
            Assert.That(exists, Is.False);
        }
Exemple #4
0
        public void Can_Perform_Delete_On_LanguageRepository()
        {
            // Arrange
            IScopeProvider provider = ScopeProvider;

            using (provider.CreateScope())
            {
                LanguageRepository repository = CreateRepository(provider);

                // Act
                ILanguage language = repository.Get(3);
                repository.Delete(language);

                bool exists = repository.Exists(3);

                // Assert
                Assert.That(exists, Is.False);
            }
        }
Exemple #5
0
 public void Delete(LanguageDM domain)
 {
     try
     {
         _LanguageRepo.Delete(domain);
     }
     catch (Exception ex)
     {
         //Errors in this scope indicates system error (not validation errors)
         //If error exist but not handled, log it and add system error
         if (!_GlobalErrors.ErrorHandled)
         {
             _Logger.Error(ex, "Service Error: Cannot Delete Languages!");
             _GlobalErrors.AddSystemError("Service Error: Cannot Delete Languages!");
             _GlobalErrors.ErrorHandled = true;
         }
         throw;
     }
 }
Exemple #6
0
        public void Can_Perform_Delete_On_LanguageRepository_With_Language_Used_As_Fallback()
        {
            // Arrange
            IScopeProvider provider = ScopeProvider;

            using (provider.CreateScope())
            {
                // Add language to delete as a fall-back language to another one
                LanguageRepository repository             = CreateRepository(provider);
                ILanguage          languageToFallbackFrom = repository.Get(5);
                languageToFallbackFrom.FallbackLanguageId = 2; // fall back to #2 (something we can delete)
                repository.Save(languageToFallbackFrom);

                // delete #2
                ILanguage languageToDelete = repository.Get(2);
                repository.Delete(languageToDelete);

                bool exists = repository.Exists(2);

                // has been deleted
                Assert.That(exists, Is.False);
            }
        }
Exemple #7
0
        public bool InsertLanguages(List <Language> languages)
        {
            UserRepository userrepo = new UserRepository();
            LanguageRepository <Language> lanrepo = new LanguageRepository <Language>();
            var lengact = userrepo.GetLanguagesByUser(languages.FirstOrDefault().UserId);


            foreach (var lan in lengact)
            {
                lanrepo.Delete(lan.Id);
            }

            try
            {
                userrepo.InsertLanguages(languages);
            }
            catch (Exception er)
            {
                return(false);
            }

            return(true);
        }
        public void Can_Perform_Delete_On_LanguageRepository()
        {
            // Arrange
            var provider = new PetaPocoUnitOfWorkProvider();
            var unitOfWork = provider.GetUnitOfWork();
            var repository = new LanguageRepository(unitOfWork);

            // Act
            var language = repository.Get(3);
            repository.Delete(language);
            unitOfWork.Commit();

            var exists = repository.Exists(3);

            // Assert
            Assert.That(exists, Is.False);
        }
Exemple #9
0
 public ResponseModel Delete(Language language)
 {
     return(_languageRepository.Delete(language));
 }
Exemple #10
0
 public bool Delete(int id)
 {
     return(_languageRepository.Delete(id));
 }