Ejemplo n.º 1
0
        private async Task <bool> SaveChangesAsync()
        {
            try
            {
                if (this.CurrentSpeaker != null)
                {
                    this.CurrentSpeaker.PropertyChanged -= this.OnCurrentSpeakerPropertyChanged;
                    if (_editView.IsAddingNew && this.CurrentSpeaker != _editView.CurrentAddItem)
                    {
                        return(true);
                    }
                    if (_hasChanges || _editView.IsAddingNew)
                    {
                        if (!this.Validate())
                        {
                            return(false);
                        }
                        this.IsBusy = true;
                        var speaker = this.CurrentSpeaker;
                        if (_editView.IsAddingNew)
                        {
                            _isChanging = true;
                            var newSpeaker = await _sessionService.AddSpeakerAsync(speaker);

                            speaker.Id = newSpeaker.Id;
                            _editView.CommitNew();
                            _isChanging = false;
                        }
                        else
                        {
                            await _sessionService.UpdateSpeakerAsync(speaker);
                        }
                        this.CurrentState = NORMAL_STATE;
                    }
                }
                this.IsBusy = false;
                _hasChanges = false;
                return(true);
            }
            catch
            {
                return(false);
            }
        }