Beispiel #1
0
        private void InsertOrUpdateAction()
        {
            _movieRecord = new MovieRecord
            {
                Id            = CurrentId,
                Name          = _name,
                Year          = _year.ToString(),
                Format        = _format,
                Distributed   = "False",
                DistributedTo = ""
            };

            try
            {
                switch (_action)
                {
                case "insert":
                    _movies.Insert(_movieRecord);
                    break;

                case "update":
                    _movies.Update(_movieRecord);
                    break;
                }
            }
            catch (Exception exception)
            {
                var e = $"'{_name}' failed to {_action} database\n Message : {exception.Message}";

                _dialogService.ShowMessage("Error", e);
            }

            _mainWindow.Populate();
        }
Beispiel #2
0
 private void ClearForm()
 {
     _movieRecord = null;
     MovieName.Focus();
     MovieName.Text = "";
     Year.Value     = Year.Maximum;
     Format.Text    = "";
 }
Beispiel #3
0
 private void LoadData(string id)
 {
     _movieRecord = _movies.GetMovieById(id);
     if (_movieRecord != null)
     {
         _currentId = _movieRecord.Id;
     }
 }
Beispiel #4
0
 private void LoadCurrentMovieData()
 {
     _movieRecord = _movies.GetMovieById(_currentId);
     if (_movieRecord != null)
     {
         MovieName.Text = _movieRecord.Name;
         Year.Value     = string.IsNullOrWhiteSpace(_movieRecord.Year)
             ? Year.Maximum
             : Convert.ToDouble(_movieRecord.Year);
         Format.Text = _movieRecord.Format;
     }
 }
Beispiel #5
0
        public IMovieRecord GetMovieByName(string name)
        {
            _movieRecord = null;

            var dataRow = _xmlDatabase.SelectByName(name);

            if (dataRow != null)
            {
                _movieRecord = new MovieRecord
                {
                    Id          = dataRow["Id"] != DBNull.Value ? dataRow["Id"].ToString() : string.Empty,
                    Name        = dataRow["Name"] != DBNull.Value ? dataRow["Name"].ToString() : string.Empty,
                    Year        = dataRow["Year"] != DBNull.Value ? dataRow["Year"].ToString() : string.Empty,
                    Format      = dataRow["Format"] != DBNull.Value ? dataRow["Format"].ToString() : string.Empty,
                    Distributed =
                        dataRow["Distributed"] != DBNull.Value ? dataRow["Distributed"].ToString() : string.Empty,
                    DistributedTo =
                        dataRow["DistributedTo"] != DBNull.Value ? dataRow["DistributedTo"].ToString() : string.Empty,
                    Watched = dataRow["Watched"] != DBNull.Value ? dataRow["Watched"].ToString() : string.Empty
                };
            }
            return(_movieRecord);
        }
Beispiel #6
0
 private void InsertOrUpdate()
 {
     _movieRecord = _movies.GetMovieById(CurrentId);
     _action      = _movieRecord != null ? "update" : "insert";
 }
Beispiel #7
0
 public void Insert(IMovieRecord movieRecord)
 {
     _xmlDatabase.Insert(movieRecord.Name, movieRecord.Year, movieRecord.Format,
                         movieRecord.Distributed, movieRecord.DistributedTo, movieRecord.Watched);
 }
Beispiel #8
0
 public void Update(IMovieRecord movieRecord)
 {
     _xmlDatabase.Update(movieRecord.Id, movieRecord.Name, movieRecord.Year, movieRecord.Format,
                         movieRecord.Distributed, movieRecord.DistributedTo, movieRecord.Watched);
 }