public IHttpActionResult MovieSubmit(MovieData model) { try { var currentDate = DateTime.Now; if (model.MovieId > 0) { _dataSource.Update(model); } else { var isExists = _dataSource.GetAllData().Any(x => x.Title.ToUpper() == model.Title.ToUpper()); if (isExists) { return(ResponseMessage(Request.CreateResponse(HttpStatusCode.BadRequest, "Movie title already exist."))); } _dataSource.Create(model); } return(Ok()); } catch (Exception ex) { return(ResponseMessage(Request.CreateResponse(HttpStatusCode.InternalServerError, ex.Message))); } }
/// <summary> /// Create updates both Source (MovieLibrary) as well as local cache /// </summary> /// <param name="Movie"></param> public void Create(Movie Movie) { try { int MovieId = movieDataSource.Create(entityMapper.ConvertSingleLocalEntityToSource(Movie)); Movie.MovieId = MovieId; cache.Create(Movie); } catch { throw; } }
public bool CreateMovie(MovieData newMovie) { try { if (_dataSrc.Create(newMovie) > 0) { _cacheHelper.RemoveFromCache(ALL_MOVIES); return(true); } return(false); } catch (Exception ex) { return(false); } }
/// <summary> /// Inserts a movie into the database /// <para>MovieData object details to be inserted</para> /// </summary> /// <returns>void</returns> public void InsertMovie(MovieData movieData) { movieDataSource.Create(movieData); }
/// <summary> /// Creates the movie. /// </summary> /// <param name="movie">The movie.</param> /// <returns>movie id</returns> public int CreateMovie(MovieDto movie) { Guard.NotNull(movie, nameof(movie)); return(_dataSource.Create(movie.ToMovieData())); }