public MoviesOwned ParsePatch(MoviesOwnedModel model, int userId, int id) { try { MoviesOwned owned = this.movieRepository.GetSingleMovieOwned(userId, id); if (model.MovieStorageTypeName != null) { var checkStorage = this.movieRepository.GetStorageType() .FirstOrDefault(s => s.StorageName == model.MovieStorageTypeName); if (checkStorage != null) { owned.StorageTypeId = checkStorage.Id; } } owned.DateModified = DateTime.Now; return(owned); } catch (Exception) { return(null); } }
public MoviesOwned Parse(MoviesOwnedModel model, int userId) { try { var moviesOwned = new MoviesOwned { UserId = userId }; if (model.MovieTitle == null) { return(null); } var movieTitleId = this.movieRepository.GetMovieTitles().FirstOrDefault(t => t.MovieTitle == model.MovieTitle); if (movieTitleId != null) { moviesOwned.MovieTitlesId = movieTitleId.Id; } var storageType = this.movieRepository.GetStorageType().FirstOrDefault(s => s.StorageName == model.MovieStorageTypeName); if (storageType != null) { moviesOwned.StorageTypeId = storageType.Id; } moviesOwned.MovieTitles = this.movieRepository.GetMovieTitles().FirstOrDefault(t => t.MovieTitle == model.MovieTitle); moviesOwned.DateAdded = DateTime.Now; moviesOwned.DateModified = DateTime.Now; return(moviesOwned); } catch { return(null); } }