コード例 #1
0
        /// <summary>
        /// Returns list of all countries from database.
        /// </summary>
        /// <returns>List list of CountryDto's</returns>
        public List<CountryDto> GetAllCountries()
        {
            //Instantiate list of dto countries which has been returned.
            List<CountryDto> listDto = new List<CountryDto>();
            try
            {
                //Before any action, it must be updated because calls from contract uses
                //only one instance of UserManager.
                dbContext.Refresh(System.Data.Objects.RefreshMode.StoreWins, dbContext.Countries);

                //list of states from entities
                List<Country> list = dbContext.Countries.OrderBy(cou => cou.Id).ToList();

                //filling the list
                foreach (Country cou in list)
                {
                    CountryDto countryDto = new CountryDto(cou.Id, cou.Name);
                    listDto.Add(countryDto);
                }
            }
            catch (Exception exception)
            {
                throw new Exception("SmartGridDataMenagers: " + exception.Message);
            }
            //returns list of all countries as list of dtoes.
            return listDto;
        }
コード例 #2
0
ファイル: CountryDtoTest.cs プロジェクト: boskomijin/SGApp
 public void CountryDtoConstructorTest()
 {
     int id = 0; // TODO: Initialize to an appropriate value
     string name = string.Empty; // TODO: Initialize to an appropriate value
     CountryDto target = new CountryDto(id, name);
     Assert.Inconclusive("TODO: Implement code to verify target");
 }
コード例 #3
0
ファイル: CountryDtoTest.cs プロジェクト: boskomijin/SGApp
 public void IdTest()
 {
     CountryDto target = new CountryDto(); // TODO: Initialize to an appropriate value
     int expected = 0; // TODO: Initialize to an appropriate value
     int actual;
     target.Id = expected;
     actual = target.Id;
     Assert.AreEqual(expected, actual);
     Assert.Inconclusive("Verify the correctness of this test method.");
 }
コード例 #4
0
ファイル: CountryDtoTest.cs プロジェクト: boskomijin/SGApp
 public void NameTest()
 {
     CountryDto target = new CountryDto(); // TODO: Initialize to an appropriate value
     string expected = string.Empty; // TODO: Initialize to an appropriate value
     string actual;
     target.Name = expected;
     actual = target.Name;
     Assert.AreEqual(expected, actual);
     Assert.Inconclusive("Verify the correctness of this test method.");
 }
コード例 #5
0
ファイル: CountryDtoTest.cs プロジェクト: boskomijin/SGApp
 public void CountryDtoConstructorTest1()
 {
     CountryDto target = new CountryDto();
     Assert.Inconclusive("TODO: Implement code to verify target");
 }