public void Save(Models.HenDepreciation depreciation) { if (depreciation.IsNew) { CreatePostRequest(depreciation); } else { CreatePutRequest(depreciation.Id, depreciation); } }
private void OnLoad(object param) { IsNew = false; Models.HenDepreciation initialValues = null; try { initialValues = service.Get((Guid)param); } catch (Exception ex) { return; } Id = initialValues.Id; Date = initialValues.Date; var loadedDatails = Mapper.Map <List <Models.HenDepreciationDetail>, List <HenDepreciationDetailViewModel> >(initialValues.Details); Details = new ObservableCollection <HenDepreciationDetailViewModel>(loadedDatails); }
void OnRefresh() { Models.HenDepreciation initialValues = service.GetInitialValues(Date); //retain current selling price foreach (var newDetail in initialValues.Details) { var detail = Details.FirstOrDefault(d => d.HouseId == newDetail.HouseId); if (detail == null) { continue; } newDetail.SellingPrice = detail.SellingPrice; } var loadedDatails = Mapper.Map <List <Models.HenDepreciationDetail>, List <HenDepreciationDetailViewModel> >(initialValues.Details); Details = new ObservableCollection <HenDepreciationDetailViewModel>(loadedDatails); }
void OnDateChanged() { if (!IsNew) { return; } Models.HenDepreciation initialValues = null; try { initialValues = service.GetInitialValues(Date); } catch (Exception ex) { //TODO find the best way to refactor error return; } var loadedDatails = Mapper.Map <List <Models.HenDepreciationDetail>, List <HenDepreciationDetailViewModel> >(initialValues.Details); Details = new ObservableCollection <HenDepreciationDetailViewModel>(loadedDatails); }