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); } }
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(); }
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; }
public List <MovieDto> GetMoviesByState(StateProductEnum state) { var movies = new List <MovieDto>(); All().ForEach(movieDto => { if (movieDto.State.Equals(state)) { movies.Add(movieDto); } }); return(movies); }
public List <VideoGameDto> GetVideoGamesByState(StateProductEnum state) { var videoGames = new List <VideoGameDto>(); All().ForEach(videoGameDto => { if (videoGameDto.State.Equals(state)) { videoGames.Add(videoGameDto); } }); return(videoGames); }
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); }
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); }
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); }
public MovieWindow(StateProductEnum stateProduct) { InitializeComponent(); _stateProduct = stateProduct; InitializeVariables(); }
public VideoGameWindow(StateProductEnum stateProduct) { InitializeComponent(); InitializeVariables(); _stateProduct = stateProduct; }
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; }
public bool HasBeenChangeState(MovieDto movie, StateProductEnum state) { movie.State = state; return(Update(movie)); }
public bool HasBeenChangeState(VideoGameDto videoGame, StateProductEnum state) { videoGame.State = state; return(Update(videoGame)); }