Esempio n. 1
0
        public Ticket CreateTicket(int reservationId, string fName, string lName, IPriceCalculationStrategy priceCalcStrat)
        {
            var res = _resRepo.Get(reservationId);

            if (res.TicketId != null)
            {
                throw new InvalidOperationException("ticket has been already issued to this reservation, unable to create another one");
            }

            var placeInRun = _runRepository.GetPlaceInRun(res.PlaceInRunId);

            var newTicket = new Ticket()
            {
                ReservationId   = res.Id,
                CreatedDate     = DateTime.Now,
                FirstName       = fName,
                LastName        = lName,
                Status          = TicketStatusEnum.Active,
                PriceComponents = new List <PriceComponent>()
            };

            newTicket.PriceComponents = priceCalcStrat.CalculatePrice(placeInRun);

            _tickRepo.Create(newTicket);
            return(newTicket);
        }
Esempio n. 2
0
 public PriceCalculationDecorator(IPriceCalculationStrategy strategy, int teaCount, int coffeeCount, int cookiesCount)
 {
     _strategy     = strategy;
     _teaCount     = teaCount;
     _coffeeCount  = coffeeCount;
     _cookiesCount = cookiesCount;
 }
Esempio n. 3
0
        public StorePage(IGameRepo gameRepo, IUserRepo userRepo, IBuyService buyService, IPriceCalculationStrategy calcStrat, LibraryPage lp, User usr)
        {
            libp             = lp;
            this._gameRepo   = gameRepo;
            this._userRepo   = userRepo;
            this._buyService = buyService;
            this._calcStrat  = calcStrat;
            storeUser        = usr;

            InitializeComponent();
            if (storeList == null)
            {
                storeList = new ObservableCollection <Game>();
            }
            //storeList = new ObservableCollection<Game> {
            //    new Game{Name=" "}
            //};


            List <string> names = new List <string>();

            storeList.Clear();
            foreach (var game in _gameRepo.getAllGames())
            {
                if (!names.Contains(game.Name))
                {
                    names.Add(game.Name);

                    storeList.Add(game);
                }
            }

            StoreLIst.Items.Clear();
            StoreLIst.ItemsSource = storeList;
        }
 public RegistrationWindow(IGameRepo gameRepo, IUserRepo userRepo, IBuyService buyService, IPriceCalculationStrategy calcStrat)
 {
     this._gameRepo   = gameRepo;
     this._userRepo   = userRepo;
     this._buyService = buyService;
     this._calcStrat  = calcStrat;
     InitializeComponent();
 }
Esempio n. 5
0
 public TicketService(ITicketRepository tickRepo, IReservationRepository resRepo,
                      IMatchRepository matchRepo, IPriceCalculationStrategy priceCalculationStrategy)
 {
     _tickRepo  = tickRepo;
     _resRepo   = resRepo;
     _matchRepo = matchRepo;
     _priceCalculationStrategy = priceCalculationStrategy;
 }
Esempio n. 6
0
 public TicketService(ITicketRepository tickRepo, IReservationRepository resRepo,
                      IPriceCalculationStrategy priceCalculationStrategy, IRunRepository runRepository)
 {
     _tickRepo      = tickRepo;
     _resRepo       = resRepo;
     _priceStr      = priceCalculationStrategy;
     _runRepository = runRepository;
 }
Esempio n. 7
0
 public OrderService(IOrderRepository orderRepository, IReservationRepository resRepo,
                     IPhoneRepository phoneRepository, IPriceCalculationStrategy priceCalculationStrategy)
 {
     _orderRepository = orderRepository;
     _resRepo         = resRepo;
     _phoneRepository = phoneRepository;
     _priceStr        = priceCalculationStrategy;
 }
Esempio n. 8
0
        public Ticket CreateTicket(int reservationId, string fName, string lName, IPriceCalculationStrategy priceCalcStrat)
        {
            LogSeverity logSev     = LogSeverity.Info;
            string      logMessage = "New ticket has been bought. Reservation ID: " + reservationId;

            _logger.Log(logMessage, logSev);

            return(_ticketService.CreateTicket(reservationId, fName, lName, priceCalcStrat));
        }
Esempio n. 9
0
        public LibraryPage(IGameRepo gameRepo, IUserRepo userRepo, IBuyService buyService, IPriceCalculationStrategy calcStrat, StorePage sp, User ActiveUser)
        {
            this._gameRepo   = gameRepo;
            this._userRepo   = userRepo;
            this._buyService = buyService;
            this._calcStrat  = calcStrat;
            this.LibraryUser = ActiveUser;
            if (sp == null)
            {
                stp = new StorePage(_gameRepo, _userRepo, _buyService, _calcStrat, this, this.LibraryUser);
            }
            else
            {
                stp = sp;
            }

            InitializeComponent();
            if (userLib == null)
            {
                userLib = new ObservableCollection <Game>();
            }
            //this.LibraryUser.UserLibrary.Clear();
            //_userRepo.UpdateUser(this.LibraryUser);
            //foreach(var libItm in _userRepo.getUserByLogin(this.LibraryUser.Login).UserLibrary)
            //{
            //    if (_gameRepo.FindById(libItm.GameId) == _gameRepo.FindByFullName("CSGO"))
            //    {

            //    }
            //    else
            //    {
            //         _buyService.BuyGame(_gameRepo.FindByFullName("CSGO"), this.LibraryUser);
            //    }
            //}


            userLib.Clear();
            foreach (var libItm in userRepo.getUsrDetails(LibraryUser.Id).UserLibrary)
            {
                userLib.Add(_gameRepo.FindById(libItm.GameId));
            }

            LibraryLIst.Items.Clear();
            LibraryLIst.ItemsSource = userLib;

            //foreach (var itm in _userRepo.getUsrDetails(LibraryUser.Id).UserLibrary)
            //{
            //    int i = 0;


            //    LibraryLIst.Resources.Add(i, _gameRepo.FindById(itm.GameId).Name);
            //    i++;

            //}
        }
Esempio n. 10
0
        public SignUpWindow(IGameRepo gameRepo, IUserRepo userRepo, IBuyService buyService, IPriceCalculationStrategy calcStrat)
        {
            //foreach (var usr in _userRepo.getAllUsers())
            //{
            //    Console.WriteLine(usr.Id.ToString());

            //}
            this._gameRepo   = gameRepo;
            this._userRepo   = userRepo;
            this._buyService = buyService;
            this._calcStrat  = calcStrat;
            InitializeComponent();
        }
Esempio n. 11
0
 public HomeController(IStadiumRepository stadiumRepo, IMatchRepository matchRepo,
                       IScheduleService scheduleService, IReservationService reservationService,
                       IPriceCalculationStrategy priceCalculationStrategy, ITicketService ticketService,
                       ITicketRepository ticketRepo, IReservationRepository reservationRepo)
 {
     _stadiumRepo              = stadiumRepo;
     _matchRepo                = matchRepo;
     _scheduleService          = scheduleService;
     _reservationService       = reservationService;
     _priceCalculationStrategy = priceCalculationStrategy;
     _ticketService            = ticketService;
     _ticketRepo               = ticketRepo;
     _reservationRepo          = reservationRepo;
 }
Esempio n. 12
0
 public OrderController(IPhoneRepository phoneRepository,
                        IReservationService resServ,
                        IOrderService orderServ,
                        IPriceCalculationStrategy priceCalcStrategy,
                        IReservationRepository reservationRepo,
                        IOrderRepository orderRepository)
 {
     _phoneRepository          = phoneRepository;
     _reservationService       = resServ;
     _orderService             = orderServ;
     _priceCalculationStrategy = priceCalcStrategy;
     _reservationRepository    = reservationRepo;
     _orderRepository          = orderRepository;
 }
Esempio n. 13
0
 public TenantController(
     IReservationService reservationService,
     IReservationRepository reservationRepository,
     ITenantRepository tenantRepository,
     IApartmentRepository apartmentRepository,
     IHomeownerRepository homeownerRepository,
     IPriceCalculationStrategy priceCalculationStrategy)
 {
     this.reservationService       = reservationService;
     this.reservationRepository    = reservationRepository;
     this.tenantRepository         = tenantRepository;
     this.apartmentRepository      = apartmentRepository;
     this.homeownerRepository      = homeownerRepository;
     this.priceCalculationStrategy = priceCalculationStrategy;
 }
Esempio n. 14
0
 public RunController(ITicketRepository tick, IRunRepository run,
                      IReservationService resServ,
                      ITicketService tickServ,
                      IPriceCalculationStrategy priceCalcStrategy,
                      IReservationRepository reservationRepo,
                      ITrainRepository trainRepo)
 {
     _tickRepo        = tick;
     _runRepo         = run;
     _resServ         = resServ;
     _tickServ        = tickServ;
     _priceCalc       = priceCalcStrategy;
     _reservationRepo = reservationRepo;
     _trainRepo       = trainRepo;
 }
        public IPriceCalculationStrategy Create(string StrategyName)
        {
            IPriceCalculationStrategy priceCalculation = null;

            switch (StrategyName)
            {
            case "DefaultCalculationStrategy":

                priceCalculation = new DefaultCalculationStrategy(pigeonRepository);
                break;

            case "DuplicatePigeonCalculationStrategy":
                priceCalculation = new DuplicatePigeonsCalculateStrategy(pigeonRepository);
                break;

            case "OnThirdPigeonDiscountCalculationStrategy":
                priceCalculation = new OnThirdPigeonDiscountCalculationStrategy(pigeonRepository);
                break;
            }
            return(priceCalculation);
        }
Esempio n. 16
0
 public PriceCalculationStrategyWithCode(IBookingAgencieRepository bookingAgencieRepository, IPriceCalculationStrategy priceCalculationStrategy)
 {
     _bookingAgencies          = bookingAgencieRepository;
     _priceCalculationStrategy = priceCalculationStrategy;
 }
Esempio n. 17
0
 public BuyService(IUserRepo userRepo, IGameRepo gameRepo, IPriceCalculationStrategy priceCalculationStrategy)
 {
     _priceCalculationStrategy = priceCalculationStrategy;
     _UserRepo = userRepo;
     _GameRepo = gameRepo;
 }
Esempio n. 18
0
        public PriceDetails GetCalculatedPrice(PriceDetailsInput details)
        {
            IPriceCalculationStrategy priceCalculationStrategy = ChoosePriceCalculationStrategy(details);

            return(priceCalculationStrategy.Calculate(details));
        }
Esempio n. 19
0
 public TeaCoffeeBedPriceCalcStrategy(IPriceCalculationStrategy priceCalculationStrategy)
 {
     _priceCalculationStrategy = priceCalculationStrategy;
 }
 public PriceCalculationAggregator(IPriceCalculationStrategy strat1, IPriceCalculationStrategy strat2)
 {
     _strat1 = strat1;
     _strat2 = strat2;
 }
 public DefaultPriceCalculationDecorator(DefaultPriceCalculationStrategy strategy, ITrainRepository trainRepository)
 {
     _strategy        = strategy;
     _trainRepository = trainRepository;
 }
 public HolidaysPriceCalculationDecorator(IPriceCalculationStrategy priceCalculationStrategy, IHolidayRepository holidayRepository)
 {
     _priceCalculationStrategy = priceCalculationStrategy;
     _holidayRepository        = holidayRepository;
 }