Beispiel #1
0
        //获取所有Tickets
        //定义虚方法,运行时决定是否调用,实现动态绑定(多态)
        public virtual TicketCreationModel Get(int id)
        {
            TicketCreationModel model = new TicketCreationModel();

            //IQueryable<Ticket> ticket = DbTickets.Tickets;
            return(model);
        }
Beispiel #2
0
        public async Task <IActionResult> Edit(TicketCreationModel tcm)
        {
            Ticket ticket = _context.Tickets.Include(t => t.Customer).Include(t => t.Reservation).First(t => t.TicketID == tcm.TicketID);

            ticket.Seat     = tcm.SeatID;
            ticket.Customer = _context.Users.First(c => c.UserID == tcm.CustomerID);
            Decimal fare = GetFare(tcm.TicketID, tcm.SeatID);

            ticket.Fare = fare;
            try
            {
                _context.Update(ticket);
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!TicketExists(ticket.TicketID))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }
            return(RedirectToAction("Description", "Reservation", new { id = ticket.Reservation.ReservationID }));;
        }
        public async Task <IHttpActionResult> Index(TicketCreationModel model)
        {
            NewTicketSummary summary = await this.newTicket.New(
                new Ticket(model.ProjectionId, model.Row, model.Column));

            if (summary.IsCreated)
            {
                return(Ok(summary.Message));
            }
            else
            {
                return(BadRequest(summary.Message));
            }
        }
Beispiel #4
0
        public async Task <IHttpActionResult> Ticket([FromUri] TicketCreationModel model)
        {
            Projection dbProj = projRepo.GetById(model.Id);

            NewCreationSummary summary = await newTicket.New(new Ticket(dbProj.StartDate, dbProj.Movie.Name, dbProj.Room.Cinema.Name, dbProj.Room.Number, model.Row, model.Column, dbProj.Id));

            var ticket = ticketRepo.Get(model.Row, model.Column, model.Id);

            if (summary.IsCreated)
            {
                await projRepo.DecreaseSeatsCount(model.Id);

                return(Ok(ticket));
            }
            else
            {
                return(BadRequest(summary.Message));
            }
        }
        public async Task <IHttpActionResult> WithoutReservation(TicketCreationModel model)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            await cancelReservations.CancelExpiredReservationsAsync(DateTime.Now);

            NewTicketSummary summary = await newTicket.NewAsync(new Ticket(model.ProjectionId, model.Row, model.Column));

            if (summary.IsCreated)
            {
                return(Ok(summary.TicketOutputReceipt));
            }
            else
            {
                return(BadRequest(summary.Message));
            }
        }
Beispiel #6
0
        /// <summary>
        /// 创建新的Tickets
        /// </summary>
        /// <param name="viewmodel"></param>
        /// <returns></returns>
        public int Create(TicketCreationModel viewmodel, string Name)
        {
            int    returnValue = -1;
            Ticket ticket;

            //ticket.TicketId
            // Ensure we have a valid viewModel to work with
            if (state.IsValid)
            {
                DateTime now = DateTime.Now;
                //string user =this.User.Identity.Name;
                ticket = new Ticket()
                {
                    AffectsCustomer    = viewmodel.AffectsCustomer,
                    Category           = viewmodel.Category,
                    CreatedBy          = Name,
                    CreatedDate        = now,
                    CurrentStatus      = "Active",
                    CurrentStatusDate  = now,
                    CurrentStatusSetBy = Name,
                    Details            = viewmodel.Details,
                    IsHtml             = false,
                    LastUpdateBy       = Name,
                    LastUpdateDate     = now,
                    Priority           = viewmodel.Priority,
                    PublishedToKb      = false,
                    TagList            = viewmodel.TagList,
                    Title = viewmodel.Title,
                    Type  = viewmodel.Type,
                    Owner = viewmodel.OtherOwner ? viewmodel.Owner : Name
                };
                DbTickets.Tickets.Add(ticket);
                ServiceDeskContext context = new ServiceDeskContext();

                DbTickets.SaveChanges();
                returnValue = ticket.TicketId;
                //return View(viewModel);
            }
            return(returnValue);
        }
        public ActionResult NewTicket()
        {
            var settings = db.Settings;

            List <SelectListItem> items;
            SelectList            list;
            SelectListItem        item;
            string name;

            name  = "Priority";
            items = new List <SelectListItem>();
            items.Add(new SelectListItem()
            {
                Text = name, Value = "", Disabled = true
            });
            foreach (string value in ServiceDeskSettingManager.PrioritiesList)
            {
                items.Add(new SelectListItem()
                {
                    Text = value, Value = value
                });
            }
            list = new SelectList(items, "Value", "Text", null, (string)"", (IEnumerable)(new string[] { "" }) as IEnumerable);
            ViewBag.PrioritiesList = list;

            name = "Ticket Type";
            //items = new List<string>();
            //items.Add(name);
            //items.AddRange(ServiceDeskSettingManager.TicketTypesList);
            //list = new SelectList(items, name, new string[] { name });
            items = new List <SelectListItem>();
            items.Add(new SelectListItem()
            {
                Text = name, Value = "", Disabled = true
            });
            foreach (string value in ServiceDeskSettingManager.TicketTypesList)
            {
                items.Add(new SelectListItem()
                {
                    Text = value, Value = value
                });
            }
            list = new SelectList(items, "Value", "Text", null, (string)"", (IEnumerable)(new string[] { "" }) as IEnumerable);
            ViewBag.TicketTypesList = list;

            name = "Category";
            //items = new List<string>();
            //items.Add(name);
            //items.AddRange(ServiceDeskSettingManager.CategoriesList);
            //list = new SelectList(items, name, new string[] { name });
            items = new List <SelectListItem>();
            items.Add(new SelectListItem()
            {
                Text = name, Value = "", Disabled = true
            });
            foreach (string value in ServiceDeskSettingManager.CategoriesList)
            {
                items.Add(new SelectListItem()
                {
                    Text = value, Value = value
                });
            }
            list = new SelectList(items, "Value", "Text", null, (string)"", (IEnumerable)(new string[] { "" }) as IEnumerable);
            ViewBag.CategoriesList = list;

            UserManager manager = UserManager.Create();
            var         users   = manager.Users.Where(u => u.UserName != this.User.Identity.Name).Select(u => u.UserName).OrderBy(n => n);

            name = "User";
            //items = new List<string>();
            //items.Add(name);
            //items.AddRange(users);
            //list = new SelectList(items, name, new string[] { name });
            items = new List <SelectListItem>();
            items.Add(new SelectListItem()
            {
                Text = name, Value = "", Disabled = true
            });
            foreach (string value in users)
            {
                items.Add(new SelectListItem()
                {
                    Text = value, Value = value
                });
            }
            list = new SelectList(items, "Value", "Text", null, (string)"", (IEnumerable)(new string[] { "" }) as IEnumerable);
            ViewBag.OwnerList = list;

            TicketCreationModel ticket = new TicketCreationModel();

            //device.PassCode = Guid.NewGuid().ToString();

            return(View(ticket));
        }
        public int Create(TicketCreationModel viewmodel)
        {
            string Name = this.User.Identity.Name;

            return(ITickets.Create(viewmodel, Name));
        }
Beispiel #9
0
        // GET: Tickets/Edit/5
        public async Task <IActionResult> Edit(int?id, Int32?UserID)
        {
            SelectList reservationCustomers;

            if (id == null)
            {
                return(NotFound());
            }

            var ticket = await _context.Tickets.Include(t => t.Reservation).Include(t => t.Customer).Include(t => t.Flight).ThenInclude(flight => flight.FlightInfo).FirstAsync(t => t.TicketID == id);

            if (ticket == null)
            {
                return(NotFound());
            }
            Int32  customerID;
            Int32  reservationID;
            String SeatID;

            try
            {
                reservationID = ticket.Reservation.ReservationID;
            }
            catch
            {
                reservationID = -1;
            }
            if (UserID.HasValue)
            {
                customerID = UserID.Value;

                reservationCustomers = await GetReservationCustomersAsync(reservationID, UserID);
            }
            else
            {
                try
                {
                    customerID = ticket.Customer.UserID;
                }
                catch
                {
                    customerID = -1;
                }

                reservationCustomers = await GetReservationCustomersAsync(reservationID, null);
            }

            try
            {
                SeatID = ticket.Seat;
            }
            catch
            {
                SeatID = "";
            }
            TicketCreationModel tcm = new TicketCreationModel
            {
                TicketID   = ticket.TicketID,
                CustomerID = customerID,
                SeatID     = SeatID
            };

            ViewBag.ReservationCustomers = reservationCustomers;

            //Fist Class, Budget price
            ViewBag.firstClassFare = ticket.Flight.FlightInfo.FirstClassFare.ToString("C");
            ViewBag.baseFare       = ticket.Flight.FlightInfo.BaseFare.ToString("C");
            ViewBag.takenSeats     = Utilities.GetTakenSeats.FromFlight(ticket.Flight.FlightID, _context);
            return(View(tcm));
        }