Esempio n. 1
0
        public void Create(StationDto stationDto)
        {
            if (!stationValidator.Validate(stationDto).IsValid)
            {
                throw new ArgumentException(stationValidator.Validate(stationDto).Errors.First().ErrorMessage);
            }

            var station = mapper.Map <StationDto, Station>(stationDto);

            uow.Stations.Create(station);
            uow.Save();
        }
Esempio n. 2
0
        internal async Task <IEnumerable <Station> > LoadStation()
        {
            _log.Verbose("Load stations from database");
            var configuration = await _configurationProvider.Load();

            var i = 0;

            return((await configuration.DatabaseLink.GetJsonAsync <List <Station> >()).Where(x =>
            {
                var result = _stationValidator.Validate(x);
                if (!result.IsValid)
                {
                    foreach (var failure in result.Errors)
                    {
                        _log.Error("Property " + failure.PropertyName + " failed validation. Error was: " + failure.ErrorMessage);
                    }
                }
                return result.IsValid;
            }).Select(st =>
            {
                st.Id = i++;
                return st;
            }));
        }
        public ActionResult Index(Ticket ticket)
        {
            if (Session["role"] != null)
            {
                StationValidator station = new StationValidator();
                ValidationResult result  = station.Validate(ticket);

                if (ticket.StartPoint == null && ticket.EndPoint == null)
                {
                }
                else
                {
                    foreach (var failure in result.Errors)
                    {
                        ModelState.AddModelError(failure.PropertyName, failure.ErrorMessage);
                    }
                }


                if (ModelState.IsValid)
                {
                    DateTime datetime = DateTime.Now;
                    ticket.DateOfPurchase = datetime;

                    double[,] ticketfare =
                    {
                        {  0.00,  1.50,  1.90,  1.90,  1.90,  2.30,  2.30,  2.80,  3.30,  3.90,  4.30,  4.70,  4.80,  4.90,  5.30,  5.40,  5.60,  5.90,  6.40,  6.50,  6.70,  6.90,  7.10,  7.10,  7.20,  7.40,  7.70, 15.10, 12.70, 11.90, 11.50, 10.00,  9.10,  9.10,  8.30,  7.60,  7.50,  7.10,  6.60,  6.70,  7.10,  7.20,  8.00,  9.00,  9.00,  9.50, 10.60, 11.10, 11.90, 12.40, 13.40, 13.90, 14.40, 16.00, 18.40, 20.00, 21.70 },
                        {  1.50,  0.00,  1.30,  1.90,  1.90,  2.00,  2.30,  2.60,  3.00,  3.60,  4.10,  4.40,  4.60,  4.60,  5.00,  5.20,  5.30,  5.60,  6.10,  6.20,  6.50,  6.60,  6.90,  7.00,  7.00,  7.20,  7.50, 14.90, 12.50, 11.60, 11.30,  9.80,  8.90,  8.90,  8.10,  7.40,  7.20,  7.10,  6.40,  6.50,  6.90,  7.00,  7.70,  8.70,  8.70,  9.30, 10.40, 10.90, 11.60, 12.20, 13.20, 13.70, 14.20, 15.80, 18.20, 19.80, 21.50 },
                        {  1.90,  1.30,  0.00,  1.60,  1.80,  1.80,  2.20,  2.40,  2.90,  3.50,  3.90,  4.30,  4.40,  4.50,  4.90,  5.00,  5.20,  5.40,  6.00,  6.10,  6.30,  6.50,  6.80,  7.00,  7.00,  7.00,  7.40, 14.70, 12.30, 11.50, 11.20,  9.70,  8.80,  8.80,  8.00,  7.20,  7.10,  7.00,  6.20,  6.30,  6.70,  7.00,  7.60,  8.60,  8.60,  9.20, 10.30, 10.80, 11.50, 12.10, 13.00, 13.60, 14.00, 15.60, 18.00, 19.60, 21.30 },
                        {  1.90,  1.90,  1.60,  0.00,  1.20,  1.80,  1.90,  2.40,  2.60,  3.20,  3.60,  4.00,  4.10,  4.20,  4.60,  4.70,  4.90,  5.20,  5.70,  5.80,  6.00,  6.20,  6.50,  6.80,  6.90,  7.00,  7.10, 14.50, 12.10, 11.30, 11.00,  9.50,  8.60,  8.50,  7.70,  7.00,  7.00,  6.70,  6.00,  6.00,  6.40,  6.80,  7.30,  8.60,  8.60,  8.90, 10.00, 10.50, 11.30, 11.90, 12.80, 13.30, 13.80, 15.40, 17.80, 19.40, 21.10 },
                        {  1.90,  1.90,  1.80,  1.20,  0.00,  1.60,  1.90,  2.30,  2.50,  3.10,  3.50,  3.80,  4.00,  4.10,  4.50,  4.60,  4.80,  5.00,  5.50,  5.70,  5.90,  6.10,  6.40,  6.60,  6.80,  6.90,  7.00, 14.40, 12.00, 11.20, 10.80,  9.40,  8.60,  8.40,  7.60,  7.00,  7.00,  6.60,  5.80,  5.90,  6.30,  6.70,  7.20,  8.50,  8.60,  8.80,  9.90, 10.40, 11.20, 11.70, 12.70, 13.20, 13.70, 15.30, 17.70, 19.30, 21.00 },
                        {  2.30,  2.00,  1.80,  1.80,  1.60,  0.00,  1.70,  2.00,  2.50,  2.80,  3.20,  3.50,  3.70,  3.80,  4.20,  4.30,  4.50,  4.70,  5.20,  5.40,  5.60,  5.80,  6.10,  6.30,  6.50,  6.60,  7.00, 14.10, 11.70, 10.90, 10.60,  9.10,  8.60,  8.10,  7.30,  6.90,  6.70,  6.30,  5.50,  5.60,  6.00,  6.40,  7.20,  8.20,  8.50,  8.50,  9.70, 10.20, 10.90, 11.50, 12.40, 13.00, 13.40, 15.00, 17.40, 19.00, 20.70 },
                        {  2.30,  2.30,  2.20,  1.90,  1.90,  1.70,  0.00,  2.00,  2.10,  2.40,  2.90,  3.20,  3.40,  3.40,  3.80,  4.00,  4.10,  4.40,  4.90,  5.00,  5.30,  5.40,  5.70,  6.00,  6.10,  6.30,  6.60, 13.80, 11.50, 10.60, 10.30,  8.80,  8.60,  7.80,  7.00,  6.50,  6.40,  5.90,  5.20,  5.30,  5.70,  6.10,  6.90,  7.90,  8.50,  8.50,  9.40,  9.90, 10.60, 11.20, 12.10, 12.70, 13.10, 14.70, 17.10, 18.70, 20.40 },
                        {  2.80,  2.60,  2.40,  2.40,  2.30,  2.00,  2.00,  0.00,  2.00,  2.20,  2.40,  2.70,  2.90,  3.00,  3.40,  3.50,  3.70,  3.90,  4.40,  4.60,  4.80,  4.90,  5.20,  5.50,  5.60,  5.80,  6.20, 13.40, 11.00, 10.20,  9.90,  9.20,  8.20,  7.30,  6.80,  6.00,  5.90,  5.40,  4.70,  4.80,  5.20,  5.60,  6.40,  7.40,  8.00,  8.50,  9.00,  9.50, 10.20, 10.80, 11.70, 12.30, 12.70, 14.30, 16.70, 18.30, 20.00 },
                        {  3.30,  3.00,  2.90,  2.60,  2.50,  2.50,  2.10,  2.00,  0.00,  2.20,  2.20,  2.30,  2.40,  2.50,  2.90,  3.00,  3.20,  3.50,  4.00,  4.10,  4.30,  4.50,  4.80,  5.00,  5.20,  5.30,  5.70, 13.00, 10.60,  9.80,  9.50,  8.80,  7.80,  7.20,  6.30,  5.60,  5.40,  5.00,  4.20,  4.30,  4.70,  5.10,  5.90,  7.00,  7.60,  8.20,  8.60,  9.10,  9.80, 10.40, 11.30, 11.90, 12.30, 13.90, 16.30, 17.90, 19.60 },
                        {  3.90,  3.60,  3.50,  3.20,  3.10,  2.80,  2.40,  2.20,  2.20,  0.00,  1.90,  1.90,  2.10,  2.20,  2.30,  2.40,  2.60,  2.90,  3.40,  3.50,  3.70,  3.90,  4.20,  4.50,  4.60,  4.70,  5.10, 12.50, 10.10,  9.30,  9.00,  8.20,  7.20,  6.60,  5.70,  5.00,  4.80,  4.40,  3.70,  3.70,  4.10,  4.50,  5.30,  6.70,  7.00,  7.60,  8.60,  8.60,  9.30,  9.90, 10.80, 11.40, 11.80, 13.40, 15.80, 17.40, 19.10 },
                        {  4.30,  4.10,  3.90,  3.60,  3.50,  3.20,  2.90,  2.40,  2.20,  1.90,  0.00,  1.70,  2.10,  2.10,  2.10,  2.30,  2.40,  2.40,  2.90,  3.10,  3.30,  3.50,  3.80,  4.00,  4.10,  4.30,  4.70, 12.20,  9.80,  8.90,  8.60,  7.80,  7.10,  6.20,  5.30,  4.50,  4.40,  4.00,  3.20,  3.30,  3.70,  4.10,  4.90,  6.20,  6.90,  7.20,  8.40,  8.60,  8.90,  9.50, 10.50, 11.00, 11.50, 13.10, 15.50, 17.10, 18.80 },
                        {  4.70,  4.40,  4.30,  4.00,  3.80,  3.50,  3.20,  2.70,  2.30,  1.90,  1.70,  0.00,  1.30,  1.50,  1.90,  1.90,  2.10,  2.40,  2.60,  2.70,  3.00,  3.10,  3.40,  3.70,  3.80,  4.00,  4.30, 11.90,  9.50,  8.60,  8.60,  7.50,  6.80,  5.80,  5.00,  4.20,  4.10,  3.60,  2.90,  3.00,  3.40,  3.80,  4.60,  5.90,  6.50,  7.20,  8.10,  8.60,  8.60,  9.20, 10.20, 10.70, 11.20, 12.80, 15.20, 16.80, 18.50 },
                        {  4.80,  4.60,  4.40,  4.10,  4.00,  3.70,  3.40,  2.90,  2.40,  2.10,  2.10,  1.30,  0.00,  1.10,  1.90,  1.90,  2.10,  2.20,  2.40,  2.60,  2.80,  3.00,  3.30,  3.50,  3.70,  3.80,  4.20, 11.70,  9.30,  8.60,  8.60,  7.30,  6.60,  5.70,  4.80,  4.10,  3.90,  3.50,  2.70,  3.00,  3.20,  3.60,  4.40,  5.80,  6.40,  7.00,  8.00,  8.50,  8.50,  9.10, 10.00, 10.60, 11.00, 12.60, 15.00, 16.60, 18.30 },
                        {  4.90,  4.60,  4.50,  4.20,  4.10,  3.80,  3.40,  3.00,  2.50,  2.20,  2.10,  1.50,  1.10,  0.00,  1.80,  1.80,  1.80,  2.10,  2.40,  2.50,  2.70,  2.90,  3.20,  3.40,  3.60,  3.70,  4.10, 11.70,  9.30,  8.60,  8.60,  7.30,  6.50,  5.60,  4.70,  4.00,  3.80,  3.40,  2.60,  2.70,  3.10,  3.50,  4.30,  5.70,  6.30,  6.90,  7.90,  8.40,  8.50,  9.00, 10.00, 10.50, 11.00, 12.60, 15.00, 16.60, 18.30 },
                        {  5.30,  5.00,  4.90,  4.60,  4.50,  4.20,  3.80,  3.40,  2.90,  2.30,  2.10,  1.90,  1.90,  1.80,  0.00,  1.20,  1.60,  2.10,  2.30,  2.30,  2.30,  2.50,  2.80,  3.10,  3.20,  3.30,  3.70, 11.30,  8.90,  8.60,  8.50,  7.20,  6.10,  5.20,  4.30,  3.60,  3.40,  3.00,  2.30,  2.30,  2.70,  3.10,  3.90,  5.30,  5.90,  6.50,  7.50,  8.10,  8.50,  8.70,  9.60, 10.20, 10.60, 12.20, 14.60, 16.20, 17.90 },
                        {  5.40,  5.20,  5.00,  4.70,  4.60,  4.30,  4.00,  3.50,  3.00,  2.40,  2.30,  1.90,  1.90,  1.80,  1.20,  0.00,  1.30,  2.00,  2.10,  2.30,  2.30,  2.40,  2.70,  2.90,  3.10,  3.20,  3.60, 11.20,  8.80,  8.60,  8.40,  7.10,  6.00,  5.10,  4.20,  3.50,  3.30,  2.90,  2.30,  2.30,  2.60,  3.00,  3.80,  5.10,  5.80,  6.40,  7.40,  7.90,  8.50,  8.60,  9.50, 10.10, 10.50, 12.10, 14.50, 16.10, 17.80 },
                        {  5.60,  5.30,  5.20,  4.90,  4.80,  4.50,  4.10,  3.70,  3.20,  2.60,  2.40,  2.10,  2.10,  1.80,  1.60,  1.30,  0.00,  1.50,  1.90,  2.10,  2.30,  2.40,  2.50,  2.80,  2.90,  3.00,  3.40, 11.10,  8.70,  8.60,  8.30,  6.90,  5.80,  4.90,  4.00,  3.30,  3.10,  2.70,  2.30,  2.30,  2.40,  2.80,  3.60,  5.00,  5.60,  6.20,  7.20,  7.80,  8.50,  8.60,  9.40,  9.90, 10.40, 12.00, 14.40, 16.00, 17.70 },
                        {  5.90,  5.60,  5.40,  5.20,  5.00,  4.70,  4.40,  3.90,  3.50,  2.90,  2.40,  2.40,  2.20,  2.10,  2.10,  2.00,  1.50,  0.00,  1.90,  2.00,  2.00,  2.20,  2.20,  2.50,  2.60,  2.80,  3.10, 10.80,  8.70,  8.40,  8.00,  6.60,  5.60,  4.60,  3.80,  3.00,  2.90,  2.40,  1.90,  2.00,  2.40,  2.60,  3.40,  4.70,  5.30,  6.00,  7.00,  7.50,  8.40,  8.60,  9.10,  9.70, 10.10, 11.70, 14.10, 15.70, 17.40 },
                        {  6.40,  6.10,  6.00,  5.70,  5.50,  5.20,  4.90,  4.40,  4.00,  3.40,  2.90,  2.60,  2.40,  2.40,  2.30,  2.10,  1.90,  1.90,  0.00,  1.20,  1.80,  2.00,  2.00,  2.30,  2.30,  2.30,  2.60, 10.40,  8.70,  7.90,  7.50,  6.10,  5.10,  4.10,  3.30,  2.50,  2.40,  2.20,  1.60,  1.80,  1.90,  2.40,  2.90,  4.20,  4.80,  5.50,  6.80,  7.00,  7.90,  8.50,  8.70,  9.20,  9.70, 11.30, 13.70, 15.30, 17.00 },
                        {  6.50,  6.20,  6.10,  5.80,  5.70,  5.40,  5.00,  4.60,  4.10,  3.50,  3.10,  2.70,  2.60,  2.50,  2.30,  2.30,  2.10,  2.00,  1.20,  0.00,  1.50,  1.80,  1.80,  2.10,  2.30,  2.30,  2.50, 10.30,  8.70,  7.80,  7.40,  6.00,  4.90,  4.00,  3.10,  2.40,  2.20,  2.10,  1.80,  1.80,  2.00,  2.40,  3.00,  4.30,  5.00,  5.60,  6.90,  7.20,  8.00,  8.60,  8.80,  9.40,  9.80, 11.40, 13.80, 15.40, 17.10 },
                        {  6.70,  6.50,  6.30,  6.00,  5.90,  5.60,  5.30,  4.80,  4.30,  3.70,  3.30,  3.00,  2.80,  2.70,  2.30,  2.30,  2.30,  2.00,  1.80,  1.50,  0.00,  1.30,  1.80,  1.80,  2.00,  2.00,  2.30, 10.10,  8.50,  7.50,  7.20,  5.80,  4.70,  3.80,  2.90,  2.40,  2.20,  2.10,  1.80,  1.80,  2.30,  2.40,  3.20,  4.60,  5.20,  5.80,  7.00,  7.40,  8.20,  8.60,  9.00,  9.50, 10.00, 11.60, 14.00, 15.60, 17.30 },
                        {  6.90,  6.60,  6.50,  6.20,  6.10,  5.80,  5.40,  4.90,  4.50,  3.90,  3.50,  3.10,  3.00,  2.90,  2.50,  2.40,  2.40,  2.20,  2.00,  1.80,  1.30,  0.00,  1.60,  1.80,  2.00,  2.00,  2.30, 10.00,  8.30,  7.40,  7.00,  5.60,  4.50,  3.60,  2.70,  2.30,  2.10,  1.90,  1.90,  2.00,  2.50,  2.60,  3.40,  4.70,  5.40,  6.00,  7.00,  7.50,  8.40,  8.60,  9.10,  9.70, 10.10, 11.70, 14.10, 15.70, 17.40 },
                        {  7.10,  6.90,  6.80,  6.50,  6.40,  6.10,  5.70,  5.20,  4.80,  4.20,  3.80,  3.40,  3.30,  3.20,  2.80,  2.70,  2.50,  2.20,  2.00,  1.80,  1.80,  1.60,  0.00,  1.60,  1.80,  2.00,  2.30, 10.20,  8.60,  7.70,  7.30,  5.90,  4.80,  3.90,  3.00,  2.30,  2.30,  1.90,  2.30,  2.30,  2.50,  2.90,  3.70,  5.00,  5.70,  6.30,  7.30,  7.80,  8.70,  8.70,  9.40,  9.90, 10.40, 12.00, 14.40, 16.00, 17.70 },
                        {  7.10,  7.00,  7.00,  6.80,  6.60,  6.30,  6.00,  5.50,  5.00,  4.50,  4.00,  3.70,  3.50,  3.40,  3.10,  2.90,  2.80,  2.50,  2.30,  2.10,  1.80,  1.80,  1.60,  0.00,  1.20,  1.60,  2.30, 10.40,  8.60,  7.90,  7.60,  6.20,  5.10,  4.20,  3.30,  2.60,  2.40,  2.30,  2.30,  2.30,  2.70,  3.10,  4.00,  5.30,  5.90,  6.60,  7.50,  8.10,  8.70,  8.70,  9.60, 10.20, 10.60, 12.20, 14.60, 16.20, 17.90 },
                        {  7.20,  7.00,  7.00,  6.90,  6.80,  6.50,  6.10,  5.60,  5.20,  4.60,  4.10,  3.80,  3.70,  3.60,  3.20,  3.10,  2.90,  2.60,  2.30,  2.30,  2.00,  2.00,  1.80,  1.20,  0.00,  1.30,  2.20, 10.60,  8.60,  8.00,  7.70,  6.30,  5.20,  4.30,  3.40,  2.70,  2.50,  2.30,  2.40,  2.50,  2.90,  3.30,  4.10,  5.40,  6.10,  6.70,  7.60,  8.20,  8.70,  8.80,  9.70, 10.30, 10.70, 12.30, 14.70, 16.30, 18.00 },
                        {  7.40,  7.20,  7.00,  7.00,  6.90,  6.60,  6.30,  5.80,  5.30,  4.70,  4.30,  4.00,  3.80,  3.70,  3.30,  3.20,  3.00,  2.80,  2.30,  2.30,  2.00,  2.00,  2.00,  1.60,  1.30,  0.00,  1.80, 10.70,  8.60,  8.20,  7.80,  6.40,  5.40,  4.50,  3.60,  2.80,  2.70,  2.30,  2.50,  2.60,  3.00,  3.40,  4.20,  5.60,  6.20,  6.80,  7.80,  8.30,  8.70,  8.90,  9.90, 10.40, 10.90, 12.50, 14.90, 16.50, 18.20 },
                        {  7.70,  7.50,  7.40,  7.10,  7.00,  7.00,  6.60,  6.20,  5.70,  5.10,  4.70,  4.30,  4.20,  4.10,  3.70,  3.60,  3.40,  3.10,  2.60,  2.50,  2.30,  2.30,  2.30,  2.30,  2.20,  1.80,  0.00, 11.00,  8.60,  8.50,  8.20,  6.80,  5.80,  4.80,  4.00,  3.20,  3.10,  2.60,  2.90,  3.00,  3.40,  3.80,  4.60,  5.90,  6.60,  7.20,  8.10,  8.70,  8.70,  9.20, 10.20, 10.70, 11.20, 12.80, 15.20, 16.80, 18.50 },
                        { 15.10, 14.90, 14.70, 14.50, 14.40, 14.10, 13.80, 13.40, 13.00, 12.50, 12.20, 11.90, 11.70, 11.70, 11.30, 11.20, 11.10, 10.80, 10.40, 10.30, 10.10, 10.00, 10.20, 10.40, 10.60, 10.70, 11.00,  0.00,  3.70,  4.70,  5.00,  6.80,  7.50,  8.40,  9.00,  9.00,  9.20,  9.50, 10.60, 10.70, 11.10, 11.40, 12.10, 13.20, 13.80, 14.30, 15.40, 15.90, 16.70, 17.30, 18.20, 18.70, 19.20, 20.80, 23.20, 24.80, 26.50 },
                        { 12.70, 12.50, 12.30, 12.10, 12.00, 11.70, 11.50, 11.00, 10.60, 10.10,  9.80,  9.50,  9.30,  9.30,  8.90,  8.80,  8.70,  8.70,  8.70,  8.70,  8.50,  8.30,  8.60,  8.60,  8.60,  8.60,  8.60,  3.70,  0.00,  2.20,  2.20,  4.00,  5.00,  6.00,  6.80,  7.30,  7.40,  7.80,  8.70,  8.70,  8.70,  9.00,  9.70, 10.80, 11.40, 11.90, 13.10, 13.50, 14.30, 14.90, 15.80, 16.40, 16.80, 18.40, 20.80, 22.40, 24.10 },
                        { 11.90, 11.60, 11.50, 11.30, 11.20, 10.90, 10.60, 10.20,  9.80,  9.30,  8.90,  8.60,  8.60,  8.60,  8.60,  8.60,  8.60,  8.40,  7.90,  7.80,  7.50,  7.40,  7.70,  7.90,  8.00,  8.20,  8.50,  4.70,  2.20,  0.00,  1.80,  3.00,  4.10,  5.00,  5.90,  6.60,  6.80,  7.20,  8.10,  8.20,  8.60,  8.90,  8.90, 10.00, 10.60, 11.10, 12.20, 12.70, 13.50, 14.00, 15.00, 15.50, 16.00, 17.60, 20.00, 21.60, 23.30 },
                        { 11.50, 11.30, 11.20, 11.00, 10.80, 10.60, 10.30,  9.90,  9.50,  9.00,  8.60,  8.60,  8.60,  8.60,  8.50,  8.40,  8.30,  8.00,  7.50,  7.40,  7.20,  7.00,  7.30,  7.60,  7.70,  7.80,  8.20,  5.00,  2.20,  1.80,  0.00,  2.60,  3.70,  4.60,  5.50,  6.20,  6.40,  6.80,  7.80,  7.90,  8.20,  8.50,  8.50,  9.70, 10.20, 10.80, 11.90, 12.40, 13.10, 13.70, 14.70, 15.20, 15.70, 17.30, 19.70, 21.30, 23.00 },
                        { 10.00,  9.80,  9.70,  9.50,  9.40,  9.10,  8.80,  9.20,  8.80,  8.20,  7.80,  7.50,  7.30,  7.30,  7.20,  7.10,  6.90,  6.60,  6.10,  6.00,  5.80,  5.60,  5.90,  6.20,  6.30,  6.40,  6.80,  6.80,  4.00,  3.00,  2.60,  0.00,  2.30,  2.90,  3.80,  4.50,  4.70,  5.10,  6.40,  6.50,  6.90,  7.00,  7.70,  8.80,  8.80,  9.30, 10.40, 10.90, 11.70, 12.20, 13.20, 13.70, 14.20, 15.80, 18.20, 19.80, 21.50 },
                        {  9.10,  8.90,  8.80,  8.60,  8.60,  8.60,  8.60,  8.20,  7.80,  7.20,  7.10,  6.80,  6.60,  6.50,  6.10,  6.00,  5.80,  5.60,  5.10,  4.90,  4.70,  4.50,  4.80,  5.10,  5.20,  5.40,  5.80,  7.50,  5.00,  4.10,  3.70,  2.30,  0.00,  2.10,  2.70,  3.50,  3.60,  4.00,  5.30,  5.40,  5.80,  6.20,  7.00,  8.00,  8.60,  9.20,  9.50, 10.00, 10.70, 11.30, 12.30, 12.80, 13.30, 14.90, 17.30, 18.90, 20.60 },
                        {  9.10,  8.90,  8.80,  8.50,  8.40,  8.10,  7.80,  7.30,  7.20,  6.60,  6.20,  5.80,  5.70,  5.60,  5.20,  5.10,  4.90,  4.60,  4.10,  4.00,  3.80,  3.60,  3.90,  4.20,  4.30,  4.50,  4.80,  8.40,  6.00,  5.00,  4.60,  2.90,  2.10,  0.00,  2.00,  2.50,  2.70,  3.10,  4.40,  4.50,  4.90,  5.30,  6.10,  7.10,  7.70,  8.30,  8.70,  9.20, 10.00, 10.50, 11.50, 12.00, 12.50, 14.10, 16.50, 18.10, 19.80 },
                        {  8.30,  8.10,  8.00,  7.70,  7.60,  7.30,  7.00,  6.80,  6.30,  5.70,  5.30,  5.00,  4.80,  4.70,  4.30,  4.20,  4.00,  3.80,  3.30,  3.10,  2.90,  2.70,  3.00,  3.30,  3.40,  3.60,  4.00,  9.00,  6.80,  5.90,  5.50,  3.80,  2.70,  2.00,  0.00,  1.90,  2.10,  2.20,  3.50,  3.60,  4.00,  4.40,  5.20,  6.60,  7.20,  7.50,  8.70,  9.20,  9.20,  9.80, 10.70, 11.30, 11.70, 13.30, 15.70, 17.30, 19.00 },
                        {  7.60,  7.40,  7.20,  7.00,  7.00,  6.90,  6.50,  6.00,  5.60,  5.00,  4.50,  4.20,  4.10,  4.00,  3.60,  3.50,  3.30,  3.00,  2.50,  2.40,  2.40,  2.30,  2.30,  2.60,  2.70,  2.80,  3.20,  9.00,  7.30,  6.60,  6.20,  4.50,  3.50,  2.50,  1.90,  0.00,  1.30,  2.20,  2.80,  2.90,  3.30,  3.70,  4.50,  5.80,  6.50,  7.10,  8.00,  8.60,  8.60,  9.10, 10.10, 10.60, 11.10, 12.70, 15.10, 16.70, 18.40 },
                        {  7.50,  7.20,  7.10,  7.00,  7.00,  6.70,  6.40,  5.90,  5.40,  4.80,  4.40,  4.10,  3.90,  3.80,  3.40,  3.30,  3.10,  2.90,  2.40,  2.20,  2.20,  2.10,  2.30,  2.40,  2.50,  2.70,  3.10,  9.20,  7.40,  6.80,  6.40,  4.70,  3.60,  2.70,  2.10,  1.30,  0.00,  2.00,  2.60,  2.70,  3.10,  3.50,  4.30,  5.70,  6.30,  6.90,  7.90,  8.40,  8.60,  9.00, 10.00, 10.50, 11.00, 12.60, 15.00, 16.60, 18.30 },
                        {  7.10,  7.10,  7.00,  6.70,  6.60,  6.30,  5.90,  5.40,  5.00,  4.40,  4.00,  3.60,  3.50,  3.40,  3.00,  2.90,  2.70,  2.40,  2.20,  2.10,  2.10,  1.90,  1.90,  2.30,  2.30,  2.30,  2.60,  9.50,  7.80,  7.20,  6.80,  5.10,  4.00,  3.10,  2.20,  2.20,  2.00,  0.00,  2.30,  2.30,  2.70,  3.10,  3.90,  5.20,  5.90,  6.50,  7.50,  8.00,  8.60,  8.60,  9.60, 10.10, 10.60, 12.20, 14.60, 16.20, 17.90 },
                        {  6.60,  6.40,  6.20,  6.00,  5.80,  5.50,  5.20,  4.70,  4.20,  3.70,  3.20,  2.90,  2.70,  2.60,  2.30,  2.30,  2.30,  1.90,  1.60,  1.80,  1.80,  1.90,  2.30,  2.30,  2.40,  2.50,  2.90, 10.60,  8.70,  8.10,  7.80,  6.40,  5.30,  4.40,  3.50,  2.80,  2.60,  2.30,  0.00,  1.10,  1.90,  2.00,  2.60,  3.90,  4.60,  5.20,  6.50,  7.00,  7.60,  8.30,  8.70,  9.00,  9.50, 11.10, 13.50, 15.10, 16.80 },
                        {  6.70,  6.50,  6.30,  6.00,  5.90,  5.60,  5.30,  4.80,  4.30,  3.70,  3.30,  3.00,  3.00,  2.70,  2.30,  2.30,  2.30,  2.00,  1.80,  1.80,  1.80,  2.00,  2.30,  2.30,  2.50,  2.60,  3.00, 10.70,  8.70,  8.20,  7.90,  6.50,  5.40,  4.50,  3.60,  2.90,  2.70,  2.30,  1.10,  0.00,  1.90,  1.90,  2.50,  3.80,  4.50,  5.10,  6.40,  7.00,  7.50,  8.20,  8.70,  8.90,  9.40, 11.00, 13.40, 15.00, 16.70 },
                        {  7.10,  6.90,  6.70,  6.40,  6.30,  6.00,  5.70,  5.20,  4.70,  4.10,  3.70,  3.40,  3.20,  3.10,  2.70,  2.60,  2.40,  2.40,  1.90,  2.00,  2.30,  2.50,  2.50,  2.70,  2.90,  3.00,  3.40, 11.10,  8.70,  8.60,  8.20,  6.90,  5.80,  4.90,  4.00,  3.30,  3.10,  2.70,  1.90,  1.90,  0.00,  1.90,  2.50,  3.40,  4.10,  4.70,  6.00,  6.60,  7.20,  7.80,  8.60,  8.60,  9.10, 10.70, 13.10, 14.70, 16.40 },
                        {  7.20,  7.00,  7.00,  6.80,  6.70,  6.40,  6.10,  5.60,  5.10,  4.50,  4.10,  3.80,  3.60,  3.50,  3.10,  3.00,  2.80,  2.60,  2.40,  2.40,  2.40,  2.60,  2.90,  3.10,  3.30,  3.40,  3.80, 11.40,  9.00,  8.90,  8.50,  7.00,  6.20,  5.30,  4.40,  3.70,  3.50,  3.10,  2.00,  1.90,  1.90,  0.00,  1.90,  3.00,  3.70,  4.30,  5.60,  6.20,  7.10,  7.40,  8.50,  8.60,  8.70, 10.30, 12.70, 14.30, 16.00 },
                        {  8.00,  7.70,  7.60,  7.30,  7.20,  7.20,  6.90,  6.40,  5.90,  5.30,  4.90,  4.60,  4.40,  4.30,  3.90,  3.80,  3.60,  3.40,  2.90,  3.00,  3.20,  3.40,  3.70,  4.00,  4.10,  4.20,  4.60, 12.10,  9.70,  8.90,  8.50,  7.70,  7.00,  6.10,  5.20,  4.50,  4.30,  3.90,  2.60,  2.50,  2.50,  1.90,  0.00,  2.20,  2.90,  3.50,  4.80,  5.40,  6.30,  6.90,  7.70,  8.30,  8.70, 10.30, 12.70, 14.30, 16.00 },
                        {  9.00,  8.70,  8.60,  8.60,  8.50,  8.20,  7.90,  7.40,  7.00,  6.70,  6.20,  5.90,  5.80,  5.70,  5.30,  5.10,  5.00,  4.70,  4.20,  4.30,  4.60,  4.70,  5.00,  5.30,  5.40,  5.60,  5.90, 13.20, 10.80, 10.00,  9.70,  8.80,  8.00,  7.10,  6.60,  5.80,  5.70,  5.20,  3.90,  3.80,  3.40,  3.00,  2.20,  0.00,  2.50,  2.50,  3.50,  4.10,  4.90,  5.60,  6.70,  7.00,  7.50,  9.10, 11.50, 13.10, 14.80 },
                        {  9.00,  8.70,  8.60,  8.60,  8.60,  8.50,  8.50,  8.00,  7.60,  7.00,  6.90,  6.50,  6.40,  6.30,  5.90,  5.80,  5.60,  5.30,  4.80,  5.00,  5.20,  5.40,  5.70,  5.90,  6.10,  6.20,  6.60, 13.80, 11.40, 10.60, 10.20,  8.80,  8.60,  7.70,  7.20,  6.50,  6.30,  5.90,  4.60,  4.50,  4.10,  3.70,  2.90,  2.50,  0.00,  2.40,  2.80,  3.40,  4.30,  5.00,  6.10,  6.70,  7.20,  8.80, 11.20, 12.80, 14.50 },
                        {  9.50,  9.30,  9.20,  8.90,  8.80,  8.50,  8.50,  8.50,  8.20,  7.60,  7.20,  7.20,  7.00,  6.90,  6.50,  6.40,  6.20,  6.00,  5.50,  5.60,  5.80,  6.00,  6.30,  6.60,  6.70,  6.80,  7.20, 14.30, 11.90, 11.10, 10.80,  9.30,  9.20,  8.30,  7.50,  7.10,  6.90,  6.50,  5.20,  5.10,  4.70,  4.30,  3.50,  2.50,  2.40,  0.00,  2.60,  2.80,  3.70,  4.30,  5.40,  6.10,  6.60,  8.20, 10.60, 12.20, 13.90 },
                        { 10.60, 10.40, 10.30, 10.00,  9.90,  9.70,  9.40,  9.00,  8.60,  8.60,  8.40,  8.10,  8.00,  7.90,  7.50,  7.40,  7.20,  7.00,  6.80,  6.90,  7.00,  7.00,  7.30,  7.50,  7.60,  7.80,  8.10, 15.40, 13.10, 12.20, 11.90, 10.40,  9.50,  8.70,  8.70,  8.00,  7.90,  7.50,  6.50,  6.40,  6.00,  5.60,  4.80,  3.50,  2.80,  2.60,  0.00,  2.30,  2.40,  3.00,  4.10,  4.80,  5.30,  6.90,  9.30, 10.90, 12.60 },
                        { 11.10, 10.90, 10.80, 10.50, 10.40, 10.20,  9.90,  9.50,  9.10,  8.60,  8.60,  8.60,  8.50,  8.40,  8.10,  7.90,  7.80,  7.50,  7.00,  7.20,  7.40,  7.50,  7.80,  8.10,  8.20,  8.30,  8.70, 15.90, 13.50, 12.70, 12.40, 10.90, 10.00,  9.20,  9.20,  8.60,  8.40,  8.00,  7.00,  7.00,  6.60,  6.20,  5.40,  4.10,  3.40,  2.80,  2.30,  0.00,  2.00,  2.40,  3.60,  4.20,  4.70,  6.30,  8.70, 10.30, 12.00 },
                        { 11.90, 11.60, 11.50, 11.30, 11.20, 10.90, 10.60, 10.20,  9.80,  9.30,  8.90,  8.60,  8.50,  8.50,  8.50,  8.50,  8.50,  8.40,  7.90,  8.00,  8.20,  8.40,  8.70,  8.70,  8.70,  8.70,  8.70, 16.70, 14.30, 13.50, 13.10, 11.70, 10.70, 10.00,  9.20,  8.60,  8.60,  8.60,  7.60,  7.50,  7.20,  7.10,  6.30,  4.90,  4.30,  3.70,  2.40,  2.00,  0.00,  2.40,  2.70,  3.30,  3.80,  5.40,  7.80,  9.40, 11.10 },
                        { 12.40, 12.20, 12.10, 11.90, 11.70, 11.50, 11.20, 10.80, 10.40,  9.90,  9.50,  9.20,  9.10,  9.00,  8.70,  8.60,  8.60,  8.60,  8.50,  8.60,  8.60,  8.60,  8.70,  8.70,  8.80,  8.90,  9.20, 17.30, 14.90, 14.00, 13.70, 12.20, 11.30, 10.50,  9.80,  9.10,  9.00,  8.60,  8.30,  8.20,  7.80,  7.40,  6.90,  5.60,  5.00,  4.30,  3.00,  2.40,  2.40,  0.00,  2.30,  2.60,  3.20,  4.80,  7.20,  8.80, 10.50 },
                        { 13.40, 13.20, 13.00, 12.80, 12.70, 12.40, 12.10, 11.70, 11.30, 10.80, 10.50, 10.20, 10.00, 10.00,  9.60,  9.50,  9.40,  9.10,  8.70,  8.80,  9.00,  9.10,  9.40,  9.60,  9.70,  9.90, 10.20, 18.20, 15.80, 15.00, 14.70, 13.20, 12.30, 11.50, 10.70, 10.10, 10.00,  9.60,  8.70,  8.70,  8.60,  8.50,  7.70,  6.70,  6.10,  5.40,  4.10,  3.60,  2.70,  2.30,  0.00,  2.40,  2.40,  4.00,  6.40,  8.00,  9.70 },
                        { 13.90, 13.70, 13.60, 13.30, 13.20, 13.00, 12.70, 12.30, 11.90, 11.40, 11.00, 10.70, 10.60, 10.50, 10.20, 10.10,  9.90,  9.70,  9.20,  9.40,  9.50,  9.70,  9.90, 10.20, 10.30, 10.40, 10.70, 18.70, 16.40, 15.50, 15.20, 13.70, 12.80, 12.00, 11.30, 10.60, 10.50, 10.10,  9.00,  8.90,  8.60,  8.60,  8.30,  7.00,  6.70,  6.10,  4.80,  4.20,  3.30,  2.60,  2.40,  0.00,  2.20,  3.80,  6.20,  7.80,  9.50 },
                        { 14.40, 14.20, 14.00, 13.80, 13.70, 13.40, 13.10, 12.70, 12.30, 11.80, 11.50, 11.20, 11.00, 11.00, 10.60, 10.50, 10.40, 10.10,  9.70,  9.80, 10.00, 10.10, 10.40, 10.60, 10.70, 10.90, 11.20, 19.20, 16.80, 16.00, 15.70, 14.20, 13.30, 12.50, 11.70, 11.10, 11.00, 10.60,  9.50,  9.40,  9.10,  8.70,  8.70,  7.50,  7.20,  6.60,  5.30,  4.70,  3.80,  3.20,  2.40,  2.20,  0.00,  1.60,  4.00,  5.60,  7.30 },
                        { 16.00, 15.80, 15.60, 15.40, 15.30, 15.00, 14.70, 14.30, 13.90, 13.40, 13.10, 12.80, 12.60, 12.60, 12.20, 12.10, 12.00, 11.70, 11.30, 11.40, 11.60, 11.70, 12.00, 12.20, 12.30, 12.50, 12.80, 20.80, 18.40, 17.60, 17.30, 15.80, 14.90, 14.10, 13.30, 12.70, 12.60, 12.20, 11.10, 11.00, 10.70, 10.30, 10.30,  9.10,  8.80,  8.20,  6.90,  6.30,  5.40,  4.80,  4.00,  3.80,  1.60,  0.00,  2.80,  5.00,  6.40 },
                        { 18.40, 18.20, 18.00, 17.80, 17.70, 17.40, 17.10, 16.70, 16.30, 15.80, 15.50, 15.20, 15.00, 15.00, 14.60, 14.50, 14.40, 14.10, 13.70, 13.80, 14.00, 14.10, 14.40, 14.60, 14.70, 14.90, 15.20, 23.20, 20.80, 20.00, 19.70, 18.20, 17.30, 16.50, 15.70, 15.10, 15.00, 14.60, 13.50, 13.40, 13.10, 12.70, 12.70, 11.50, 11.20, 10.60,  9.30,  8.70,  7.80,  7.20,  6.40,  6.20,  4.00,  2.80,  0.00,  2.80,  4.70 },
                        { 20.00, 19.80, 19.60, 19.40, 19.30, 19.00, 18.70, 18.30, 17.90, 17.40, 17.10, 16.80, 16.60, 16.60, 16.20, 16.10, 16.00, 15.70, 15.30, 15.40, 15.60, 15.70, 16.00, 16.20, 16.30, 16.50, 16.80, 24.80, 22.40, 21.60, 21.30, 19.80, 18.90, 18.10, 17.30, 16.70, 16.60, 16.20, 15.10, 15.00, 14.70, 14.30, 14.30, 13.10, 12.80, 12.20, 10.90, 10.30,  9.40,  8.80,  8.00,  7.80,  5.60,  5.00,  2.80,  0.00,  2.90 },
                        { 21.70, 21.50, 21.30, 21.10, 21.00, 20.70, 20.40, 20.00, 19.60, 19.10, 18.80, 18.50, 18.30, 18.30, 17.90, 17.80, 17.70, 17.40, 17.00, 17.10, 17.30, 17.40, 17.70, 17.90, 18.00, 18.20, 18.50, 26.50, 24.10, 23.30, 23.00, 21.50, 20.60, 19.80, 19.00, 18.40, 18.30, 17.90, 16.80, 16.70, 16.40, 16.00, 16.00, 14.80, 14.50, 13.90, 12.60, 12.00, 11.10, 10.50,  9.70,  9.50,  7.30,  6.40,  4.70,  2.90,  0.00 },
                    };

                    IDictionary <int, string> location = new Dictionary <int, string>()
                    {
                        { 0, "Pelabuhan Klang" },
                        { 1, "Jalan Kastam" },
                        { 2, "Kg. Raja Uda" },
                        { 3, "Teluk Gadong" },
                        { 4, "Teluk Pulai" },
                        { 5, "Klang" },
                        { 6, "Bukit Badak" },
                        { 7, "Padang Jawa" },
                        { 8, "Shah Alam" },
                        { 9, "Batu Tiga" },
                        { 10, "Subang Jaya" },
                        { 11, "Setia Jaya" },
                        { 12, "Seri Setia" },
                        { 13, "Kg. Dato Harun" },
                        { 14, "Jalan Templer" },
                        { 15, "Petaling" },
                        { 16, "Pantai Dalam" },
                        { 17, "AngkasaPuri" },
                        { 18, "KL Sentral" },
                        { 19, "Kuala Lumpur" },
                        { 20, "Bank Negara" },
                        { 21, "Putra" },
                        { 22, "Sentul" },
                        { 23, "Batu Kentonmen" },
                        { 24, "Kg. Batu" },
                        { 25, "Taman Wahyu" },
                        { 26, "Batu Caves" },
                        { 27, "Tanjung Malim" },
                        { 28, "Kuala Kubu" },
                        { 29, "Rasa" },
                        { 30, "Batang Kali" },
                        { 31, "Serendah" },
                        { 32, "Rawang" },
                        { 33, "Kuang" },
                        { 34, "Sungai Buloh" },
                        { 35, "Kepong Sentral" },
                        { 36, "Kepong" },
                        { 37, "Segambut" },
                        { 38, "Mid Valley" },
                        { 39, "Seputeh" },
                        { 40, "Salak Selatan" },
                        { 41, "Bandar Tasik Selatan" },
                        { 42, "Serdang" },
                        { 43, "Kajang" },
                        { 44, "UKM" },
                        { 45, "Bangi" },
                        { 46, "Batang Benar" },
                        { 47, "Nilai" },
                        { 48, "Labu" },
                        { 49, "Tiroi" },
                        { 50, "Seremban" },
                        { 51, "Senawang" },
                        { 52, "Sungai Gadut" },
                        { 53, "Rembau" },
                        { 54, "Tampin" },
                        { 55, "Batang Melaka" },
                        { 56, "Gemas" }
                    };

                    int startIndex = int.Parse(ticket.StartPoint);
                    int endIndex   = int.Parse(ticket.EndPoint);
                    ticket.StartPoint = location[startIndex];
                    ticket.EndPoint   = location[endIndex];

                    ticket.BaseDiscountRate = 0.2;
                    ticket.CatDiscountRate  = 0;
                    int wayType = 1;

                    if (ticket.Category.Equals("Regular"))
                    {
                        ticket.CatDiscountRate = 0.00;
                    }
                    else if (ticket.Category.Equals("Students"))
                    {
                        ticket.CatDiscountRate = 0.50;
                    }
                    else if (ticket.Category.Equals("Senior citizens"))
                    {
                        ticket.CatDiscountRate = 0.30;
                    }
                    else if (ticket.Category.Equals("Disabled"))
                    {
                        ticket.CatDiscountRate = 0.30;
                    }

                    if (ticket.WayType.Equals("One Way"))
                    {
                        wayType = 1;
                    }
                    else if (ticket.WayType.Equals("Return"))
                    {
                        wayType = 2;
                    }

                    ticket.InitialPrice   = ticketfare[startIndex, endIndex];
                    ticket.TotalPrice     = ticket.InitialPrice * (1 - ticket.BaseDiscountRate) * (1 - ticket.CatDiscountRate) * ticket.Quantity * wayType;
                    ticket.DateOfPurchase = DateTime.Now;

                    ticket.Users.UserId = Convert.ToInt32(Session["UserId"]);
                    ticket.Users.Name   = Session["UserName"].ToString();
                    ticket.Users.ICpass = Session["UserICPassport"].ToString();
                    ticket.Users.Email  = Session["UserEmail"].ToString();


                    SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["StoreContext"].ConnectionString);
                    SqlCommand    cmd  = new SqlCommand("spInsertTicket", conn);
                    cmd.CommandType = CommandType.StoredProcedure;
                    cmd.Parameters.AddWithValue("@UserId", ticket.Users.UserId);
                    cmd.Parameters.AddWithValue("@StartPoint", ticket.StartPoint);
                    cmd.Parameters.AddWithValue("@EndPoint", ticket.EndPoint);
                    cmd.Parameters.AddWithValue("@Category", ticket.Category);
                    cmd.Parameters.AddWithValue("@WayType", ticket.WayType);
                    cmd.Parameters.AddWithValue("@Quantity", ticket.Quantity);
                    cmd.Parameters.AddWithValue("@InitialPrice", ticket.InitialPrice);
                    cmd.Parameters.AddWithValue("@BaseDiscountRate", ticket.BaseDiscountRate);
                    cmd.Parameters.AddWithValue("@CatDiscountRate", ticket.CatDiscountRate);
                    cmd.Parameters.AddWithValue("@TotalPrice", ticket.TotalPrice);
                    cmd.Parameters.AddWithValue("@DateOfPurchase", ticket.DateOfPurchase);

                    try
                    {
                        conn.Open();
                        cmd.ExecuteNonQuery();
                    }
                    catch (Exception ex)
                    {
                        ex.ToString();
                        //return View();
                    }
                    finally
                    {
                        conn.Close();
                    }

                    return(View("IndexResult", ticket));
                }
                else
                {
                    return(View());
                }
            }
            else
            {
                return(RedirectToAction("Signup"));
            }
        }