예제 #1
0
 private static void CheckProductByState(StateRentalEnum stateRental, StateProductEnum stateProduct,
                                         ProductDto productDto, ICollection <RentalDto> rentalsByState,
                                         RentalDto rental)
 {
     if (rental.State.Equals(stateRental) && productDto.State.Equals(stateProduct))
     {
         rentalsByState.Add(rental);
     }
 }
예제 #2
0
        private async void MovieStateComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            var stateEnumSelected = _itemsStateProduct.FirstOrDefault(x => x.Value.Equals(((ComboBox)sender).SelectedValue)).Key;

            if (stateEnumSelected.Equals(_stateProduct))
            {
                return;
            }
            _stateProduct = stateEnumSelected;
            await LoadDataGrid();
        }
예제 #3
0
 private static void AddMovie(MovieDto movie,
     string title, decimal price, int quantityDisc, int productionYear, int buyYear,
     TimeSpan durationTimeSpan, StateProductEnum state)
 {
     movie.Title = title;
     movie.Price = price;
     movie.QuantityDisc = quantityDisc;
     movie.ProductionYear = productionYear;
     movie.BuyYear = buyYear;
     movie.Duration = durationTimeSpan;
     movie.State = state;
 }
예제 #4
0
        public List <MovieDto> GetMoviesByState(StateProductEnum state)
        {
            var movies = new List <MovieDto>();

            All().ForEach(movieDto =>
            {
                if (movieDto.State.Equals(state))
                {
                    movies.Add(movieDto);
                }
            });

            return(movies);
        }
예제 #5
0
        public List <VideoGameDto> GetVideoGamesByState(StateProductEnum state)
        {
            var videoGames = new List <VideoGameDto>();

            All().ForEach(videoGameDto =>
            {
                if (videoGameDto.State.Equals(state))
                {
                    videoGames.Add(videoGameDto);
                }
            });

            return(videoGames);
        }
예제 #6
0
        public static ProductDto HasBeenChangeStateProduct(RentalDto rentalDto, StateProductEnum stateNew, out bool result)
        {
            ProductDto product;

            if (rentalDto.ProductId.Contains(CommonHelper.Movie))
            {
                product = MovieService.Instance.Get(rentalDto.ProductId);
                result  = MovieService.Instance.HasBeenChangeState((MovieDto)product, stateNew);
            }
            else
            {
                product = VideoGameService.Instance.Get(rentalDto.ProductId);
                result  = VideoGameService.Instance.HasBeenChangeState((VideoGameDto)product, stateNew);
            }

            return(product);
        }
예제 #7
0
        public List <RentalDto> GetRentalsByState(StateRentalEnum stateRental, StateProductEnum stateProduct)
        {
            var rentals        = All();
            var rentalsByState = new List <RentalDto>();

            rentals.ForEach(rental =>
            {
                if (rental.ProductId.Contains(CommonHelper.Movie))
                {
                    var movie = MovieService.Instance.Get(rental.ProductId);
                    CheckProductByState(stateRental, stateProduct, movie, rentalsByState, rental);
                }
                else
                {
                    var videoGame = VideoGameService.Instance.Get(rental.ProductId);
                    CheckProductByState(stateRental, stateProduct, videoGame, rentalsByState, rental);
                }
            });
            return(rentalsByState);
        }
예제 #8
0
        public bool StartRentalProduct(RentalDto rentalDto, int quantityRental, StateProductEnum stateNew, out decimal price)
        {
            bool result;

            price = 0;
            try
            {
                var finishRental = rentalDto.StartRental.AddDays(quantityRental);
                rentalDto.FinishRental = finishRental;
                result = Add(rentalDto, out var id);
                if (!result)
                {
                    return(false);
                }

                var product = CommonService.HasBeenChangeStateProduct(rentalDto, stateNew, out result);

                price = product.Price;

                if (result)
                {
                    ClientService.Instance.AddQuantityRental(rentalDto.ClientId);
                    var rental = Get(id);
                    var client = ClientService.Instance.Get(rental.ClientId);
                    price       *= quantityRental;
                    price       -= price * decimal.Divide(client.Discount, 100);
                    rental.Price = decimal.Round(price, 2);
                    rental.State = StateRentalEnum.Activated;
                    Update(rental);
                }
            }
            catch (Exception exception)
            {
                Helper.HandleLogError(exception.Message);
                result = false;
            }

            return(result);
        }
예제 #9
0
 public MovieWindow(StateProductEnum stateProduct)
 {
     InitializeComponent();
     _stateProduct = stateProduct;
     InitializeVariables();
 }
예제 #10
0
 public VideoGameWindow(StateProductEnum stateProduct)
 {
     InitializeComponent();
     InitializeVariables();
     _stateProduct = stateProduct;
 }
예제 #11
0
 private static void AddVideoGame(VideoGameDto videoGame,
     string title, decimal price, int quantityDisc, GamePlatformEnum platformEnum, StateProductEnum state)
 {
     videoGame.Title = title;
     videoGame.Price = price;
     videoGame.QuantityDisc = quantityDisc;
     videoGame.Platform = platformEnum;
     videoGame.State = state;
 }
예제 #12
0
 public bool HasBeenChangeState(MovieDto movie, StateProductEnum state)
 {
     movie.State = state;
     return(Update(movie));
 }
예제 #13
0
 public bool HasBeenChangeState(VideoGameDto videoGame, StateProductEnum state)
 {
     videoGame.State = state;
     return(Update(videoGame));
 }