Exemple #1
0
        /// <summary>
        /// This method shows the information of the selected ticket
        /// <example>tickets/Details/1</example>
        /// <example>tickets/Details/4</example>
        /// </summary>
        /// <param name="id">ID of the selected ticket</param>
        /// <returns>Details of the ticket which ID is given</returns>

        public ActionResult Details(int id)
        {
            ShowTicket showTicket = new ShowTicket();

            //Get the current ticket from the database
            string url = "TicketData/FindTicket/" + id;
            HttpResponseMessage response = client.GetAsync(url).Result;

            if (response.IsSuccessStatusCode)
            {
                TicketDto SelectedTicket = response.Content.ReadAsAsync <TicketDto>().Result;
                showTicket.Ticket = SelectedTicket;

                //Get the user/owner of the selected ticket
                url      = "TicketData/GetTicketUser/" + id;
                response = client.GetAsync(url).Result;
                ApplicationUserDto SelectedUser = response.Content.ReadAsAsync <ApplicationUserDto>().Result;
                showTicket.User = SelectedUser;

                //Get the parking spot of the selected ticket
                url      = "TicketData/GetTicketSpot/" + id;
                response = client.GetAsync(url).Result;
                ParkingSpotDto SelectedSpot = response.Content.ReadAsAsync <ParkingSpotDto>().Result;
                showTicket.Spot = SelectedSpot;

                return(View(showTicket));
            }
            else
            {
                return(RedirectToAction("Error"));
            }
        }
        public IHttpActionResult GetAllTickets()
        {
            //List of the tickets from the database
            List <Ticket> Tickets = db.Tickets.ToList();

            //Data transfer object to show information about the ticket
            List <ShowTicket> TicketDtos = new List <ShowTicket> {
            };

            foreach (var Ticket in Tickets)
            {
                ShowTicket ticket = new ShowTicket();

                //Get the user to which the ticket belongs to
                ApplicationUser user = db.Users.Where(u => u.Tickets.Any(t => t.TicketId == Ticket.TicketId)).FirstOrDefault();

                ApplicationUserDto parentUser = new ApplicationUserDto
                {
                    Id        = user.Id,
                    FirstName = user.FirstName,
                    LastName  = user.LastName
                };
                //Get the parking spot of ticket
                ParkingSpot Spot = db.Spots.Where(s => s.Tickets.Any(t => t.TicketId == Ticket.TicketId)).FirstOrDefault();

                ParkingSpotDto spot = new ParkingSpotDto
                {
                    SpotId     = Spot.SpotId,
                    Zone       = Spot.Zone,
                    SpotNumber = Spot.SpotNumber,
                    Status     = Spot.Status
                };



                TicketDto NewTicket = new TicketDto
                {
                    TicketId    = Ticket.TicketId,
                    NumberPlate = Ticket.NumberPlate,
                    EntryTime   = Ticket.EntryTime,
                    Duration    = Ticket.Duration,
                    Fees        = 5 * Ticket.Duration,
                    Id          = Ticket.Id,
                    SpotId      = Ticket.SpotId
                };

                ticket.Ticket = NewTicket;
                ticket.Spot   = spot;
                ticket.User   = parentUser;
                TicketDtos.Add(ticket);
            }

            return(Ok(TicketDtos));
        }
Exemple #3
0
 private void SelectTicket(object sender, SelectionChangedEventArgs e)
 {
     if (ticketList.SelectedItem is TictetCar tictetCar)
     {
         ShowTicket ticket = new ShowTicket(tictetCar.Ticket);
         if (ticket.ShowDialog().Value)
         {
             context = new taxiEntities();
             ShowResult();
         }
     }
 }
        public ActionResult Details(int id)
        {
            ShowTicket ViewModel = new ShowTicket();
            // ViewModel.isadmin = User.IsInRole("Admin");
            string url = "TicketData/FindTicket/" + id;
            HttpResponseMessage response = client.GetAsync(url).Result;

            //Debug.WriteLine(response.StatusCode);
            if (response.IsSuccessStatusCode)
            {
                TicketDTO SelectedTicket = response.Content.ReadAsAsync <TicketDTO>().Result;
                ViewModel.Ticket = SelectedTicket;
                return(View(ViewModel));
            }
            else
            {
                return(RedirectToAction("Error"));
            }
        }
Exemple #5
0
 private void Show(object sender, SelectionChangedEventArgs e)
 {
     try
     {
         if (ticketList.SelectedItem is ticket ticket1)
         {
             ShowTicket ticket = new ShowTicket(ticket1);
             if (ticket.ShowDialog().Value)
             {
                 context = new taxiEntities();
                 ticketList.ItemsSource = context.ticket.ToList();
             }
         }
     }
     catch (Exception ex)
     {
         MsgBox.Error(ex.Message);
     }
 }