public void Add_InvalidPath_TmxFile_Test()
        {
            // Assign
            AbstractLanguageRepository repository = new LanguageRepository();

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

            // Assert
            Assert.IsFalse(result);
            Assert.IsFalse(File.Exists(MockObjects.NonEXIST_Add_TmxFilePath.FullName));
        }
Exemplo n.º 2
0
        private LanguageRepository ReadLanguages(XElement xmlElement, XNamespace xmlNamespace)
        {
            LanguageRepository languageRepository = new LanguageRepository();

            IEnumerable <Language> languages = from language in xmlElement.Descendants(xmlNamespace + MusicXmlConstants.LANGUAGE_NODE)
                                               select new Language()
            {
                Id   = language.Attribute(MusicXmlConstants.LANGUAGE_ID).Value,
                Name = language.Value
            };

            foreach (Language language in languages)
            {
                languageRepository.Add(language);
            }

            return(languageRepository);
        }
Exemplo n.º 3
0
 public void Add(LanguageDM domain)
 {
     try
     {
         _LanguageRepo.Add(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 Add Languages!");
             _GlobalErrors.AddSystemError("Service Error: Cannot Add Languages!");
             _GlobalErrors.ErrorHandled = true;
         }
         throw;
     }
 }
Exemplo n.º 4
0
        public static void Main(string[] args)
        {
            Startup s = new Startup(new HostingEnvironment()
            {
                ContentRootPath = AppContext.BaseDirectory
            });
            DbContextOptionsBuilder <EmployeeContext> optionsBuilder = new DbContextOptionsBuilder <EmployeeContext>();

            optionsBuilder.UseSqlServer(@"Server=(localdb)\mssqllocaldb;Database=FuckYou;Trusted_Connection=True;MultipleActiveResultSets=True");

            using (var db = new EmployeeContext(optionsBuilder.Options))
            {
                LanguageRepository <EmployeeContext> lr = new LanguageRepository <EmployeeContext>(db);

                // add language;
                if (!lr.GetAll().Any(l => l.Code == "EE"))
                {
                    lr.Add(new Language {
                        Name = "Eesti", Code = "EE"
                    });
                }


                Language ll = lr.GetAll().Where(l => l.Code == "EE").FirstOrDefault();


                EntityBaseRepository <EducationLevel, EmployeeContext> elr = new EntityBaseRepository <EducationLevel, EmployeeContext>(db);

                // add language;
                if (!elr.GetAll().Any(l => l.Code == "ah"))
                {
                    elr.Add(new EducationLevel {
                        Name = "Algharidus", Code = "ah"
                    });
                }

                EducationLevel el = elr.GetAll().Where(l => l.Code == "ah").FirstOrDefault();

                Education edu = new Education();
                edu.SchoolName    = "Uus kool";
                edu.YearCompleted = 2015;
                edu.NameOfDegree  = "uu";
                edu.Level         = el;


                Employee EE = new Employee {
                    Name = "Siim Aus", EmployeeId = "0203"
                };
                ContactData cd = new ContactData();
                EE.ContactData = cd;
                cd.Education.Add(edu);
                cd.FirstName       = "Siim";
                cd.LastName        = "Aus";
                cd.JobTitle        = "IT Director";
                cd.ContactLanguage = ll;
                edu.ContactData    = cd;
                edu.ContactDataId  = cd.Id;
                db.Employees.Add(EE);
                db.SaveChanges();

                EmployeeRepository <EmployeeContext> er = new EmployeeRepository <EmployeeContext>(db);


                foreach (Employee ex in er.GetAll().Where(x => x.Id >= 9))
                {
                    //Include(c => c.ContactData).ThenInclude(e => )
                    string json = Newtonsoft.Json.JsonConvert.SerializeObject(ex, Formatting.Indented,
                                                                              new JsonSerializerSettings {
                        ReferenceLoopHandling = ReferenceLoopHandling.Ignore
                                                //,
                                                //PreserveReferencesHandling = PreserveReferencesHandling.Objects
                    });
                    Console.WriteLine("{0} {1} {2}\n{3}", ex.Id, ex.Name, ex.EmployeeId, json);
                }
            }

            testSerialize();



            Console.WriteLine("Hello World!");
        }
Exemplo n.º 5
0
 public bool Add(Language language)
 {
     return(_languageRepository.Add(language));
 }
Exemplo n.º 6
0
 public void AddLanguage(language language)
 {
     _languageRepository.Add(language);
 }