Ejemplo n.º 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)));
            }
        }
Ejemplo n.º 2
0
 public bool UpdateMovie(MovieData movie)
 {
     try
     {
         _dataSrc.Update(movie);
         _cacheHelper.RemoveFromCache(ALL_MOVIES);
         return(true);
     }
     catch (Exception ex)
     {
         return(false);
     }
 }
Ejemplo n.º 3
0
 /// <summary>
 /// Switches ids so that moviedata can contain the movie to be updated
 /// </summary>
 /// <param name="Id"></param>
 /// <param name="Movie"></param>
 private void UpdateSource(int Id, Movie Movie)
 {
     try
     {
         // MovieData movieData = entityMapper.ConvertSingleLocalEntityToSource(Movie);
         Movie movieData = new Movie()
         {
             MovieId = Id
         };
         movieDataSource.Update(movieData);
     }
     catch
     {
         throw;
     }
 }
Ejemplo n.º 4
0
 /// <summary>
 /// Updates the movieData into database
 /// <para>MovieDataTobeUpdated into contains movieId as well for which the updation has to be done.</para>
 /// </summary>
 /// <returns>void</returns>
 public void UpdateMovie(MovieData movieData)
 {
     movieDataSource.Update(movieData);
 }
 /// <summary>
 ///     Updates the movie.
 /// </summary>
 /// <param name="movie">The movie.</param>
 public void UpdateMovie(MovieDto movie)
 {
     Guard.NotNull(movie, nameof(movie));
     _dataSource.Update(movie.ToMovieData());
 }