public DealViewModel GetDealViewModel() { return this.InvokeIfRequired(() => { if(!dealId.HasValue) { return null; } this.errorProvider.Clear(); if (!this.Validate()) { return null; } this.commentUserControl.Validate(); var viewModel = new DealViewModel { Id = dealId.Value, Name = this.textBoxDealName.Text, Comment = this.commentUserControl.Rtf, Reference = this.textBoxReference.Text, StartDate = this.dateTimePickerDealBegin.Value, EndDate = this.dateTimePickerDealEnd.Value }; return viewModel; }); }
private int ComputeHashcode(DealViewModel viewModel) { int hash = 23; hash = hash * 31 + viewModel.Id.GetHashCode(); hash = hash * 31 + viewModel.Name.GetHashCode(); hash = hash * 31 + (viewModel.Reference == null ? 0 : viewModel.Reference.GetHashCode()); hash = hash * 31 + (viewModel.Comment == null ? 0 : viewModel.Comment.GetHashCode()); hash = hash * 31 + viewModel.StartDate.GetHashCode(); hash = hash * 31 + viewModel.EndDate.GetHashCode(); return hash; }
public void SetDealViewModel(DealViewModel viewModel) { this.InvokeIfRequired(() => { if (viewModel != null) { this.dealId = viewModel.Id; this.textBoxDealName.Text = viewModel.Name; this.textBoxReference.Text = viewModel.Reference; this.dateTimePickerDealBegin.Value = viewModel.StartDate; this.dateTimePickerDealEnd.Value = viewModel.EndDate; this.commentUserControl.Rtf = viewModel.Comment; this.textBoxTotalDays.Text = string.Format(CultureInfo.InvariantCulture, "{0:0.##} h", viewModel.TotalDays); this.textBoxTotalPrice.Text = string.Format(CultureInfo.InvariantCulture, "{0:0.##} €", viewModel.TotalPrice); } else { this.dealId = null; this.textBoxDealName.Text = string.Empty; this.textBoxReference.Text = string.Empty; this.dateTimePickerDealBegin.Value = DateTime.Now; this.dateTimePickerDealEnd.Value = DateTime.Now; this.commentUserControl.Rtf = string.Empty; this.textBoxTotalDays.Text = string.Empty; this.textBoxTotalPrice.Text = string.Empty; } }); }
public void SetDealViewModel(DealViewModel viewModel) { }