예제 #1
0
        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)));
            }
        }
예제 #2
0
 /// <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;
     }
 }
예제 #3
0
 public bool CreateMovie(MovieData newMovie)
 {
     try
     {
         if (_dataSrc.Create(newMovie) > 0)
         {
             _cacheHelper.RemoveFromCache(ALL_MOVIES);
             return(true);
         }
         return(false);
     }
     catch (Exception ex)
     {
         return(false);
     }
 }
예제 #4
0
 /// <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()));
        }