public SnowtamDetailViewModel(SnowtamDetail snowtam,SnowtamService snowtamService, SnowtamDetailService snowtamDetailService, ObservableCollection<WorkspaceViewModel> parent,WorkspaceViewModel ntmWorkspace) { parentWorkSpaces = parent; NotamWorkspace = ntmWorkspace; if (snowtam == null) throw new ArgumentNullException("notam"); if (snowtamService == null) throw new ArgumentNullException("snowtamService"); _snowtam = snowtam; _snowtamDetailService = snowtamDetailService; _snowtamService = snowtamService; this.validators = this.GetType() .GetProperties() .Where(p => this.GetValidations(p).Length != 0) .ToDictionary(p => p.Name, p => this.GetValidations(p)); this.propertyGetters = this.GetType() .GetProperties() .Where(p => this.GetValidations(p).Length != 0) .ToDictionary(p => p.Name, p => this.GetValueGetter(p)); }
public void Send() { if (!this.ValidateType()) { MessageBox.Show(this.strLastError); } else { if (string.IsNullOrEmpty(this.DateTimeT)) { string text = string.IsNullOrEmpty(this.ObsrvDate2) ? "0" : this.ObsrvDate2; string text2 = string.IsNullOrEmpty(this.ObsrvDate3) ? "0" : this.ObsrvDate3; this.DateTimeT = ((int.Parse(text) > int.Parse(text2)) ? text : text2); if (!string.IsNullOrEmpty(this.DateTimeB)) { this.DateTimeT = ((int.Parse(this.DateTimeB) > int.Parse(this.DateTimeT)) ? this.DateTimeB : this.DateTimeT); } } if (string.IsNullOrEmpty(this._snowtam.Number)) { // Snowtam lastThisDayeSnowtam = this._snowtamService.GetLastThisDayeSnowtam(); // if (lastThisDayeSnowtam == null) { // if (!this._snowtamService.ContainsSnowtam(this._snowtam)) // { // this._snowtamService.UpdateWithNumber(this._snowtam); // } } // else // { // this._snowtamService.Delete(lastThisDayeSnowtam); // this._snowtamService.Reload(); // this._snowtamService.UpdateWithNumber(this._snowtam); // } } else this._snowtamService.Update(this._snowtam); base.OnPropertyChanged("SnowtamNum"); base.OnPropertyChanged("DisplayName"); SnowtamDetail snowtam = SnowtamDetail.CreateNewNotamDetail(this._snowtam); SnowtamDetailService snowtamDetailService = new SnowtamDetailService(this._snowtamService._dataContext); SnowtamDetail byNotamId = snowtamDetailService.GetByNotamId(this._snowtam.Id); if (byNotamId != null) { snowtam = byNotamId; } SnowtamDetailViewModel snowtamDetailViewModel = new SnowtamDetailViewModel(snowtam, _snowtamService, snowtamDetailService, this.parentWorkSpaces, this); this.parentWorkSpaces.Add(snowtamDetailViewModel); base.SetActiveWorkspace(snowtamDetailViewModel); } }