Esempio n. 1
0
 protected virtual void DeserializeChildren(PersistanceReader ip)
 {
     while (ip.HasChild)
     {
         object obj = (object)ip.GetChild();
         if (obj is Player)
         {
             this.m_Players.Add(obj as Player);
         }
         else if (obj is IgnoreList)
         {
             this.m_IgnoreList = obj as IgnoreList;
         }
         else if (obj is TravelAgent)
         {
             this.m_TravelAgent = obj as TravelAgent;
         }
     }
     if (this.m_IgnoreList == null)
     {
         this.m_IgnoreList = new IgnoreList();
     }
     if (this.m_TravelAgent != null)
     {
         return;
     }
     this.m_TravelAgent = new TravelAgent();
 }
Esempio n. 2
0
        public void Init()
        {
            singleTripPrice = 1000;
            travelAgent     = new TravelAgent(singleTripPrice);
            dailyInterest   = travelAgent.GetDailyInterest();

            aprilTrip = travelAgent.Trips.First(trip => trip.StartDate.Month == 04);
            mayTrip   = travelAgent.Trips.First(trip => trip.StartDate.Month == 05);
            juneTrip  = travelAgent.Trips.First(trip => trip.StartDate.Month == 06);
            julyTrip  = travelAgent.Trips.First(trip => trip.StartDate.Month == 07);

            firstTimeFred = new Traveler();

            diligentDave = new Traveler();
            diligentDave.Bookings.Add(new Booking {
                BookingCode = BookingCode.PaidFor, Trip = aprilTrip
            });
            diligentDave.Bookings.Add(new Booking {
                BookingCode = BookingCode.PaidFor, Trip = mayTrip
            });
            diligentDave.Bookings.Add(new Booking {
                BookingCode = BookingCode.PaidFor, Trip = juneTrip
            });

            negligentNick = new Traveler();
        }
Esempio n. 3
0
        public void TestMethod7() // проверка паспортных данных
        {
            TravelAgent agent = new TravelAgent("TestUser");
            string      res   = agent.test();

            Assert.AreEqual(res, "YES");
        }
Esempio n. 4
0
        public async Task <IActionResult> Edit(int id, [Bind("TravelAgentId,AgentName,Role")] TravelAgent travelAgent)
        {
            if (id != travelAgent.TravelAgentId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(travelAgent);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!TravelAgentExists(travelAgent.TravelAgentId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction("Index"));
            }
            return(View(travelAgent));
        }
Esempio n. 5
0
        public TravelAgent Build()
        {
            var ta = new TravelAgent {
                EntityId             = _ind,
                IataId               = _iataId,
                CommissionType       = _t,
                GivenName            = _givenName ?? string.Empty,
                FamilyName           = _familyName ?? string.Empty,
                BusinessAddress1     = _businessAddress1 ?? string.Empty,
                BusinessAddress2     = _businessAddress2 ?? string.Empty,
                BusinessCity         = _businessCity ?? string.Empty,
                BusinessState        = _businessState ?? string.Empty,
                BusinessZip          = _businessZIP ?? string.Empty,
                BusinessNation       = _businessNation ?? string.Empty,
                BusinessPhoneNumber  = _businessPhoneNumber ?? string.Empty,
                BusinessFaxNumber    = _businessFAXNumber ?? string.Empty,
                BusinessEmailAddress = _businessEmailAddress ?? string.Empty
            };

            if (_t == CommissionType.FlatPerBooking)
            {
                ta.CommissionAmount = new DecimalDollars(_commAmt).ToPb;
            }
            else if (_t == CommissionType.PercentOfBooking)
            {
                ta.CommissionPercentage = _commAmt.ToFPR();
            }
            else
            {
                throw new NotImplementedException();
            }

            return(ta);
        }
Esempio n. 6
0
 public Server(string name)
     : this()
 {
     this.m_Name        = name;
     this.m_IgnoreList  = new IgnoreList();
     this.m_TravelAgent = new TravelAgent();
 }
 public void Init()
 {
     travelAgent       = new TravelAgent(1000);
     goodTimeOfBooking = new DateTime(2018, 05, 11);
     badTimeOfBooking1 = new DateTime(2018, 05, 27);
     badTimeOfBooking2 = new DateTime(2018, 04, 11);
     tripToBook        = travelAgent.Trips.First(trip => trip.StartDate > timeOfBooking);
     traveler          = new Traveler();
 }
        private void ValidateAgentBeforeApplyChanges(TravelAgent agent)
        {
            var cantAddOrDelete = agent.ChangeTracker.State == ObjectState.Deleted || agent.ChangeTracker.State == ObjectState.Deleted;

            ValidateCondition(cantAddOrDelete, "Can't add or delete an agent.");

            var cantModify = agent.Bookings.Any(b => b.ChangeTracker.State == ObjectState.Modified && b.BookingDate < DateTime.Today);

            ValidateCondition(cantModify, "Can't modify an expired booking.");
        }
 public void SubmitAgentBookings(TravelAgent agent)
 {
     using (var context = new EFRecipesEntities())
     {
         ValidateAgentBeforeApplyChanges(agent);
         context.TravelAgents.ApplyChanges(agent);
         ValidateAgentAfterApplyChanges(context);
         context.SaveChanges();
     }
 }
Esempio n. 10
0
        public async Task <IActionResult> Create([Bind("TravelAgentId,AgentName,Role")] TravelAgent travelAgent)
        {
            if (ModelState.IsValid)
            {
                _context.Add(travelAgent);
                await _context.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }
            return(View(travelAgent));
        }
Esempio n. 11
0
        public void TestMethod5() //добавление группы
        {
            TravelAgent agent    = new TravelAgent("TestUser");
            int         expected = agent.testCount() + 1;

            agent.addTest();
            int actual = agent.testCount();

            agent.deleteTest();
            Assert.AreEqual(expected, actual);
        }
        public void Init()
        {
            travelAgent   = new TravelAgent(1000);
            timeOfBooking = new DateTime(2018, 05, 11);
            tripToBook    = travelAgent.Trips.First(trip => trip.StartDate > timeOfBooking);

            diligentDave = new Traveler();
            diligentDave.Bookings.Add(new Booking {
                BookingCode = BookingCode.PaidFor
            });
            diligentDave.Bookings.Add(new Booking {
                BookingCode = BookingCode.PaidFor
            });
            diligentDave.Bookings.Add(new Booking {
                BookingCode = BookingCode.PaidFor
            });

            negligentNick = new Traveler();
            negligentNick.Bookings.Add(new Booking {
                BookingCode = BookingCode.PaidFor
            });
            negligentNick.Bookings.Add(new Booking {
                BookingCode = BookingCode.Unpaid
            });
            negligentNick.Bookings.Add(new Booking {
                BookingCode = BookingCode.Unpaid
            });
            negligentNick.Bookings.Add(new Booking {
                BookingCode = BookingCode.Unpaid
            });

            firstTimeFred = new Traveler();

            travelerTed = new Traveler();
            travelerTed.Bookings.Add(new Booking {
                BookingCode = BookingCode.PaidFor
            });
            travelerTed.Bookings.Add(new Booking {
                BookingCode = BookingCode.PaidFor
            });
            travelerTed.Bookings.Add(new Booking {
                BookingCode = BookingCode.PaidFor
            });
            travelerTed.Bookings.Add(new Booking {
                BookingCode = BookingCode.Unpaid
            });
            travelerTed.Bookings.Add(new Booking {
                BookingCode = BookingCode.Unpaid
            });
        }
Esempio n. 13
0
        public static void Run()
        {
            // Concrete Builder
            VacationBuilder builder = new VacationBuilder();

            // Director
            TravelAgent travelAgent = new TravelAgent();

            travelAgent.ConstructPlanner(builder);

            // Getting product ...
            Planner trip = builder.GetVacationPlanner();

            trip.Print();
        }
Esempio n. 14
0
 public TravelAgent GetById(int id)
 {
     try
     {
         string sql = "SELECT Email, Password FROM TravelAgent WHERE TravelAgentId = @TravelAgentId";
         List<KeyValuePair<string, string>> parameters = new List<KeyValuePair<string, string>>()
         {
             new KeyValuePair<string, string>("@TravelAgentId", id.ToString())
         };
         DataSet results = ExecuteSql(sql, parameters);
         TravelAgent ta = DataSetParser.DataSetToTravelAgent(results, 0);
         return ta;
     }
     catch
     {
         return null;
     }
 }
Esempio n. 15
0
        /// <summary>
        /// Update changes to TravelAgent, implementing Action-Based Routing in Web API
        /// </summary>
        public HttpResponseMessage Update(TravelAgent travelAgent)
        {
            using (var context = new Recipe3Context())
            {
                var newParentEntity = true;

                // adding the object graph makes the context aware of entire
                // object graph (parent and child entites) and assigns a state
                // of added to each entity.
                context.TravelAgents.Add(travelAgent);

                if (travelAgent.AgentId > 0)
                {
                    // as the Id property has a value greater than 0, we assume
                    // that travel agent already exists and set entity state to
                    // be updated.
                    context.Entry(travelAgent).State = EntityState.Modified;
                    newParentEntity = false;
                }

                // iterate through child entites, assigning correct state.
                foreach (var booking in travelAgent.Bookings)
                {
                    if (booking.BookingId > 0)
                    {
                        // assume booking already exists if ID is greater than zero.
                        // set entity to be updated.
                        context.Entry(booking).State = EntityState.Modified;
                    }
                }

                context.SaveChanges();

                HttpResponseMessage response;

                // set Http Status code based on operation type
                response = Request.CreateResponse(newParentEntity
                    ? HttpStatusCode.Created
                    : HttpStatusCode.OK, travelAgent);

                return(response);
            }
        }
Esempio n. 16
0
        public bool AddAgentToAgency(int agencyId, int agentId)
        {
            bool result = false;

            Agency      dbAgency = db.Agencies.FirstOrDefault(x => x.Id == agencyId);
            TravelAgent dbAgent  = db.TravelAgents.FirstOrDefault(x => x.Id == agentId);


            if (dbAgency != null && dbAgent != null)
            {
                dbAgent.AgencyId = dbAgency.Id;

                db.Entry(dbAgent).State = EntityState.Modified;

                result = db.SaveChanges() > 0;
            }

            return(result);
        }
        private void InsertAgent()
        {
            using (var context = new EFRecipesEntities())
            {
                // delete any previous test data
                context.ExecuteStoreCommand("delete from chapter9.booking");
                context.ExecuteStoreCommand("delete from chapter9.travelagent");

                // inser the test data
                var agent = new TravelAgent {
                    Name = "John Tate"
                };
                var booking = new Booking {
                    Customer = "Karen Stevens", Paid = false, BookingDate = DateTime.Parse("2/2/2010")
                };
                agent.Bookings.Add(booking);
                context.TravelAgents.AddObject(agent);
                context.SaveChanges();
            }
        }
Esempio n. 18
0
        public List<TravelAgent> GetAll()
        {
            List<TravelAgent> travelAgentList = new List<TravelAgent>();
            try
            {
                string sql = "SELECT TravelAgentId, Email, Password FROM TravelAgent";
                DataSet results = ExecuteSql(sql, new List<KeyValuePair<string, string>>());

                for (int x = 0; x < results.Tables[0].Rows.Count; x++)
                {
                    TravelAgent ta = DataSetParser.DataSetToTravelAgent(results, x);
                    travelAgentList.Add(ta);
                }
                return travelAgentList;
            }
            catch
            {
                return null;
            }
        }
Esempio n. 19
0
 public void MergeFrom(GroupBooking other)
 {
     if (other == null)
     {
         return;
     }
     if (other.entityId_ != null)
     {
         if (entityId_ == null)
         {
             entityId_ = new global::HOLMS.Types.Booking.Indicators.GroupBookingIndicator();
         }
         EntityId.MergeFrom(other.EntityId);
     }
     if (other.Status != 0)
     {
         Status = other.Status;
     }
     if (other.TaxExempt != false)
     {
         TaxExempt = other.TaxExempt;
     }
     if (other.TaxId.Length != 0)
     {
         TaxId = other.TaxId;
     }
     if (other.GroupPaysLodging != false)
     {
         GroupPaysLodging = other.GroupPaysLodging;
     }
     if (other.GroupPaysIncidentals != false)
     {
         GroupPaysIncidentals = other.GroupPaysIncidentals;
     }
     if (other.AdditionalNotes.Length != 0)
     {
         AdditionalNotes = other.AdditionalNotes;
     }
     if (other.CustomerBookingId.Length != 0)
     {
         CustomerBookingId = other.CustomerBookingId;
     }
     if (other.dateRange_ != null)
     {
         if (dateRange_ == null)
         {
             dateRange_ = new global::HOLMS.Types.Primitive.PbInclusiveOpsdateRange();
         }
         DateRange.MergeFrom(other.DateRange);
     }
     if (other.rateSchedule_ != null)
     {
         if (rateSchedule_ == null)
         {
             rateSchedule_ = new global::HOLMS.Types.Supply.RateScheduleIndicator();
         }
         RateSchedule.MergeFrom(other.RateSchedule);
     }
     if (other.group_ != null)
     {
         if (group_ == null)
         {
             group_ = new global::HOLMS.Types.CRM.Groups.GroupIndicator();
         }
         Group.MergeFrom(other.Group);
     }
     if (other.confirmationTemplateId_ != null)
     {
         if (confirmationTemplateId_ == null)
         {
             confirmationTemplateId_ = new global::HOLMS.Types.Primitive.Uuid();
         }
         ConfirmationTemplateId.MergeFrom(other.ConfirmationTemplateId);
     }
     if (other.bookingMethod_ != null)
     {
         if (bookingMethod_ == null)
         {
             bookingMethod_ = new global::HOLMS.Types.TenancyConfig.Indicators.GroupBookingMethodIndicator();
         }
         BookingMethod.MergeFrom(other.BookingMethod);
     }
     if (other.arrivalTemplateId_ != null)
     {
         if (arrivalTemplateId_ == null)
         {
             arrivalTemplateId_ = new global::HOLMS.Types.Primitive.Uuid();
         }
         ArrivalTemplateId.MergeFrom(other.ArrivalTemplateId);
     }
     if (other.reservationSourceId_ != null)
     {
         if (reservationSourceId_ == null)
         {
             reservationSourceId_ = new global::HOLMS.Types.Primitive.Uuid();
         }
         ReservationSourceId.MergeFrom(other.ReservationSourceId);
     }
     if (other.travelAgent_ != null)
     {
         if (travelAgent_ == null)
         {
             travelAgent_ = new global::HOLMS.Types.Booking.Indicators.TravelAgentIndicator();
         }
         TravelAgent.MergeFrom(other.TravelAgent);
     }
     if (other.cancellationPolicy_ != null)
     {
         if (cancellationPolicy_ == null)
         {
             cancellationPolicy_ = new global::HOLMS.Types.Booking.Indicators.CancellationPolicyIndicator();
         }
         CancellationPolicy.MergeFrom(other.CancellationPolicy);
     }
     if (other.GroupName.Length != 0)
     {
         GroupName = other.GroupName;
     }
 }
Esempio n. 20
0
        public override int GetHashCode()
        {
            int hash = 1;

            if (entityId_ != null)
            {
                hash ^= EntityId.GetHashCode();
            }
            if (Status != 0)
            {
                hash ^= Status.GetHashCode();
            }
            if (TaxExempt != false)
            {
                hash ^= TaxExempt.GetHashCode();
            }
            if (TaxId.Length != 0)
            {
                hash ^= TaxId.GetHashCode();
            }
            if (GroupPaysLodging != false)
            {
                hash ^= GroupPaysLodging.GetHashCode();
            }
            if (GroupPaysIncidentals != false)
            {
                hash ^= GroupPaysIncidentals.GetHashCode();
            }
            if (AdditionalNotes.Length != 0)
            {
                hash ^= AdditionalNotes.GetHashCode();
            }
            if (CustomerBookingId.Length != 0)
            {
                hash ^= CustomerBookingId.GetHashCode();
            }
            if (dateRange_ != null)
            {
                hash ^= DateRange.GetHashCode();
            }
            if (rateSchedule_ != null)
            {
                hash ^= RateSchedule.GetHashCode();
            }
            if (group_ != null)
            {
                hash ^= Group.GetHashCode();
            }
            if (confirmationTemplateId_ != null)
            {
                hash ^= ConfirmationTemplateId.GetHashCode();
            }
            if (bookingMethod_ != null)
            {
                hash ^= BookingMethod.GetHashCode();
            }
            if (arrivalTemplateId_ != null)
            {
                hash ^= ArrivalTemplateId.GetHashCode();
            }
            if (reservationSourceId_ != null)
            {
                hash ^= ReservationSourceId.GetHashCode();
            }
            if (travelAgent_ != null)
            {
                hash ^= TravelAgent.GetHashCode();
            }
            if (cancellationPolicy_ != null)
            {
                hash ^= CancellationPolicy.GetHashCode();
            }
            if (GroupName.Length != 0)
            {
                hash ^= GroupName.GetHashCode();
            }
            return(hash);
        }