/// <summary>
        /// Add 'ticket' to the db.
        /// </summary>
        /// <param name="entity"></param>
        /// <returns></returns>
        public bool Add(AllTicketsModel entity)
        {
            _methodName = "Add(AllTicketsModel entity) fail...";

            try
            {
                if (entity == null)
                {
                    return(false);
                }

                _context.Tickets.Add(new Ticket
                {
                    TicketID    = entity.TicketID,
                    FlightID    = entity.FlightID,
                    PassengerID = entity.PassengerID,
                    CashierID   = entity.CashierID,
                    RateID      = entity.RateID,
                    SaleDate    = entity.SaleDate,
                    TotalCost   = entity.TotalCost
                });

                if (Save())
                {
                    return(true);
                }

                DebugWrite(_methodName, String.Empty);
                return(false);
            }
            catch (NullReferenceException ex)
            {
                DebugWrite(_methodName, ex.Message);
                return(false);
            }
            catch (ArgumentException ex)
            {
                DebugWrite(_methodName, ex.Message);
                return(false);
            }
            catch (Exception ex)
            {
                DebugWrite(_methodName, ex.Message);
                return(false);
            }
        }
Example #2
0
        /// <summary>
        /// Check and calculate the cost.
        /// </summary>
        private decimal CheckCost()
        {
            if (this.Flight != null && this.Tariff != null)
            {
                decimal cost = AllTicketsModel.CalculateFullCost(this.Flight, this.Tariff);

                if (cost == Decimal.MinusOne)
                {
                    return(Decimal.MinusOne);
                }
                else
                {
                    return(cost);
                }
            }
            else
            {
                return(Decimal.MinValue);
            }
        }
Example #3
0
        public IHttpActionResult GetAllTickets()
        {
            AllTicketsModel model = _ticketsService.GetAllTickets();

            return(Ok(model));
        }
 public bool Update(AllTicketsModel entity)
 {
     throw new NotImplementedException();
 }