ProvinceViewModel Map(Province province) { ProvinceViewModel provinceViewModel = new ProvinceViewModel(); provinceViewModel. Id = province.Id; provinceViewModel. Name = province.Name; provinceViewModel. Description = province.Description; if (province.Country != null) { provinceViewModel.CountryId = _countryRepository.GetById(province.Country.Id).Id; } if (province.Country != null) { provinceViewModel.CountryName = _countryRepository.GetById(province.Country.Id).Name; } provinceViewModel.IsActive = province._Status == EntityStatus.Active ? true : false; return provinceViewModel; //return new ProvinceViewModel //{ // Id = province.Id, // Name = province.Name, // Description = province.Description, // CountryId=_countryRepository.GetById(province.countryId.Id ).Id , // CountryName=_countryRepository.GetById(province.countryId.Id ).Name, // IsActive = province._Status, //}; }
public void Save(ProvinceViewModel provinceViewModel) { Province province = new Province(provinceViewModel.Id) { Name = provinceViewModel.Name, Description = provinceViewModel.Description, Country = _countryRepository.GetById(provinceViewModel.CountryId ) }; //province._SetStatus(EntityStatus.Active); _provincesRepository.Save(province); }
private void AssertProvince(Province province, Province savedProvince) { Assert.AreEqual(province.Description, savedProvince.Description); Assert.AreEqual(province.Name, savedProvince.Name); Assert.AreEqual(province.Country, savedProvince.Country); Assert.AreEqual(province._Status, EntityStatus.Active); }
public ProvinceDTO Map(Province province) { if (province == null) return null; return Mapper.Map<Province, ProvinceDTO>(province); }
protected Guid AddProvince(string Name, string Description, Guid CountryId) { Province province = new Province(Guid.NewGuid()) { Name = Name, Description = Description, Country = _countryRepository.GetById(CountryId) }; province._SetStatus(EntityStatus.Active); return _provinceRepository.Save(province); }