public void Update(Street street) { if (IsValid(street)) { repository.Update(street); } }
public void UpdateProvince(ProvinceViewModel provoinceVm) { var province = Mapper.Map <ProvinceViewModel, Province>(provoinceVm); //District var newdistricts = province.Districts; //new districts added var addedDistricts = newdistricts.Where(x => x.Id == 0).ToList(); //get updated districts var updatedDistricts = newdistricts.Where(x => x.Id != 0).ToList(); //Existed districts var existedDistricts = _disctrictRepository.FindAll(x => x.ProvinceId == provoinceVm.Id); province.Districts.Clear(); //Ward var newwards = province.Wards; //new wards added var addedWards = newwards.Where(x => x.Id == 0).ToList(); //get updated wards var updatedWards = newwards.Where(x => x.Id != 0).ToList(); //Existed wards var existedWards = _wardRepository.FindAll(x => x.ProvinceId == provoinceVm.Id); province.Wards.Clear(); var newtreets = province.Streets; //new districts added var addedTreets = newtreets.Where(x => x.Id == 0).ToList(); //get updated districts var updatedTreets = newtreets.Where(x => x.Id != 0).ToList(); //Existed details var existedTreets = _streetRepository.FindAll(x => x.ProvinceId == provoinceVm.Id); //Clear db province.Streets.Clear(); foreach (var district in updatedDistricts) { _disctrictRepository.Update(district); } foreach (var ward in updatedWards) { _wardRepository.Update(ward); } foreach (var street in updatedTreets) { _streetRepository.Update(street); } }
public void Update(StreetViewModel streetVm) { var street = Mapper.Map <StreetViewModel, Street>(streetVm); _streetRepository.Update(street); }