public void Execute(UserDto dto)
        {
            var userFromDb = context.Users.Find(dto.Id);

            userFromDb.Password = CommonMethods.ConvertToEncrypt(userFromDb.Password);

            mapper.Map(dto, userFromDb);

            validator.ValidateAndThrow(dto);

            context.SaveChanges();
        }
Exemple #2
0
        public void Execute(int id)
        {
            var movie = context.Movies.Find(id);

            if (movie == null)
            {
                throw new EntityNotFoundException(id, typeof(Movie));
            }

            movie.IsDeleted = true;
            context.SaveChanges();
        }
Exemple #3
0
        public void Execute(int id)
        {
            var actor = context.Actors.Find(id);

            if (actor == null)
            {
                throw new EntityNotFoundException(id, typeof(Actor));
            }

            actor.IsDeleted = true;
            context.SaveChanges();
        }
        public void Execute(int id)
        {
            var genre = context.Genres.Find(id);

            if (genre == null)
            {
                throw new EntityNotFoundException(id, typeof(Genre));
            }

            genre.IsDeleted = true;
            context.SaveChanges();
        }
        public void Execute(int id)
        {
            var user = context.Users.Find(id);

            if (user == null)
            {
                throw new EntityNotFoundException(id, typeof(User));
            }

            //context.Users.Remove(user);
            user.IsDeleted = true;
            context.SaveChanges();
        }
 public bool AddReview(Review review)
 {
     try
     {
         using (var db = new MovieReviewContext())
         {
             review.ReviewId = Guid.NewGuid();
             review.Date     = DateTime.Now;
             db.Review.Add((review));
             db.SaveChanges();
             return(true);
         }
     } catch
     {
         return(false);
     }
 }
        public bool DeleteReview(Guid reviewId)
        {
            try
            {
                using (var db = new MovieReviewContext())
                {
                    Review deleteReview = db.Review.Where(r => r.ReviewId == reviewId).FirstOrDefault();
                    db.Review.Remove(deleteReview);
                    db.SaveChanges();

                    return(true);
                }
            }
            catch
            {
                return(false);
            }
        }