public void Create(AreaInfoVM infoVM, EventHandler <RestClientEventArgs <AreaInfoVM> > callback) { string relativeUrl = "/CommonService/Area/Create"; var msg = infoVM.ConvertVM <AreaInfoVM, AreaInfo>((s, t) => { if (!s.provinceSysNo.HasValue) { t.ProvinceName = s.AreaName; } else if (!s.CitySysNo.HasValue && s.provinceSysNo.HasValue) { t.CityName = s.AreaName; } //else if (!string.IsNullOrEmpty(s.DistrictName)) t.DistrictName = s.AreaName; else if (s.CitySysNo.HasValue) { t.DistrictName = s.AreaName; } }); restClient.Create <AreaInfoVM>(relativeUrl, msg, (s, args) => { if (args.FaultsHandle()) { return; } infoVM = args.Result; callback(s, new RestClientEventArgs <AreaInfoVM>(infoVM, restClient.Page)); }); }
public void Update(AreaInfoVM _viewMode, EventHandler <RestClientEventArgs <AreaInfoVM> > callback) { string relativeUrl = "/CommonService/Area/Update"; var msg = _viewMode.ConvertVM <AreaInfoVM, AreaInfo>((s, t) => { if (string.IsNullOrEmpty(s.DistrictName) && string.IsNullOrEmpty(s.CityName)) { t.ProvinceName = s.AreaName; t.ProvinceSysNo = null; } else if (string.IsNullOrEmpty(s.DistrictName) && !string.IsNullOrEmpty(s.CityName)) { t.CityName = s.AreaName; t.CitySysNo = null; } else if (!string.IsNullOrEmpty(s.DistrictName)) { t.DistrictName = s.AreaName; } }); restClient.Update(relativeUrl, msg, callback); }