Ejemplo n.º 1
0
        /// <summary>
        /// Rent a handset.
        /// </summary>
        /// <param name="customer">The customer requesting the handset rental.</param>
        /// <returns>A new handset rental.</returns>
        public HandsetRental RentHandset(Customer customer)
        {
            var handset = this.GetAvailableHandsets(DateTime.Now).First();

            var rental = new HandsetRental
            {
                Customer      = customer,
                Handset       = handset,
                WhenRentedOut = DateTime.Now,
                RentalExpires = new DateTime(DateTime.Today.Year, DateTime.Today.Month, DateTime.Today.Day, 23, 59, 59),
                Pin           = this.GeneratePin()
            };

            this._persistence.GetRepository <HandsetRental>().Add(rental);

            this._persistence.Commit();

            return(rental);
        }
Ejemplo n.º 2
0
 /// <summary>
 /// Initialises a new instance of the <see cref="AuthenticatedHandset"/> class.
 /// </summary>
 /// <param name="rental">The <see cref="HandsetRental"/> that was used to authenticate the request.</param>
 public AuthenticatedHandset(HandsetRental rental)
 {
     this.Rental = rental;
 }
Ejemplo n.º 3
0
 /// <summary>
 /// Set a <see cref="HandsetRental"/> to be inactive now.
 /// </summary>
 /// <param name="rental">The <see cref="HandsetRental"/> to deactivate.</param>
 public void ExpireRental(HandsetRental rental)
 {
     rental.RentalExpires = DateTime.Now;
     this._persistence.Commit();
 }
 /// <summary>
 /// Set a <see cref="HandsetRental"/> to be inactive now.
 /// </summary>
 /// <param name="rental">The <see cref="HandsetRental"/> to deactivate.</param>
 public void ExpireRental(HandsetRental rental)
 {
     rental.RentalExpires = DateTime.Now;
     this._persistence.Commit();
 }
        /// <summary>
        /// Rent a handset.
        /// </summary>
        /// <param name="customer">The customer requesting the handset rental.</param>
        /// <returns>A new handset rental.</returns>
        public HandsetRental RentHandset(Customer customer)
        {
            var handset = this.GetAvailableHandsets(DateTime.Now).First();

            var rental = new HandsetRental
            {
                Customer = customer,
                Handset = handset,
                WhenRentedOut = DateTime.Now,
                RentalExpires = new DateTime(DateTime.Today.Year, DateTime.Today.Month, DateTime.Today.Day, 23, 59, 59),
                Pin = this.GeneratePin()
            };

            this._persistence.GetRepository<HandsetRental>().Add(rental);

            this._persistence.Commit();

            return rental;
        }
 /// <summary>
 /// Initialises a new instance of the <see cref="AuthenticatedHandset"/> class.
 /// </summary>
 /// <param name="rental">The <see cref="HandsetRental"/> that was used to authenticate the request.</param>
 public AuthenticatedHandset(HandsetRental rental)
 {
     this.Rental = rental;
 }