Esempio n. 1
0
        private string DecideColor(RentalState state, DateTime endsAt)
        {
            string color = string.Empty;

            switch (state)
            {
            case RentalState.Lended:
                if (endsAt < DateTime.Now)
                {
                    color = "red";
                }
                else
                {
                    color = "blue";
                }
                break;

            case RentalState.NotLended:
                color = "orange";
                break;

            case RentalState.Returned:
                color = "green";
                break;
            }

            return(color);
        }
Esempio n. 2
0
        private string DecideTitle(RentalState state, DateTime endsAt)
        {
            string text = string.Empty;

            switch (state)
            {
            case RentalState.Lended:
                if (endsAt < DateTime.Now)
                {
                    text = Localization.Admin.Calendar_NotReturned;
                }
                else
                {
                    text = Localization.Admin.Calendar_Lended;
                }
                break;

            case RentalState.NotLended:
                text = text = Localization.Admin.Calendar_NotLended;
                break;

            case RentalState.Returned:
                text = Localization.Admin.Calendar_Returned;
                break;
            }

            return(text);
        }
 public void DispenseKeys()
 {
     if( rentalState == RentalState.ApartmentRented )
     {
         Output( "Here are your keys." );
         rentalState = RentalState.Waiting;
         return;
     }
     BadStateResponse();
 }
Esempio n. 4
0
 public void DispenseKeys()
 {
     if (rentalState == RentalState.ApartmentRented)
     {
         Output("Here are your keys.");
         rentalState = RentalState.Waiting;
         return;
     }
     BadStateResponse();
 }
        public void SubmitApplication()
        {
            switch( rentalState )
            {
                case RentalState.GotApplication :
                    Output( "We already have your application" );
                    return;
                case RentalState.Waiting :
                    rentalState = RentalState.GotApplication;
                    Output( "Thanks for the Application." );
                    return;
            }

            BadStateResponse();
        }
Esempio n. 6
0
        public void SubmitApplication()
        {
            switch (rentalState)
            {
            case RentalState.GotApplication:
                Output("We already have your application");
                return;

            case RentalState.Waiting:
                rentalState = RentalState.GotApplication;
                Output("Thanks for the Application.");
                return;
            }

            BadStateResponse();
        }
        public void CheckApplication()
        {
            if( rentalState == RentalState.GotApplication )
            {
                bool isApproved = ( new Random( DateTime.Now.Millisecond ).Next() % 10 ) > 4;

                if( isApproved && numberOfApartments > 0 )
                {
                    Output( "Congratulation, you were approved." );
                    rentalState = RentalState.ApartmentRented;
                    RentAppartment();
                }
                else
                {
                    Output( "Sorry, you were not approved" );
                    rentalState = RentalState.Waiting;
                }
                return;
            }

            BadStateResponse();
        }
Esempio n. 8
0
        public void CheckApplication()
        {
            if (rentalState == RentalState.GotApplication)
            {
                bool isApproved = (new Random(DateTime.Now.Millisecond).Next() % 10) > 4;

                if (isApproved && numberOfApartments > 0)
                {
                    Output("Congratulation, you were approved.");
                    rentalState = RentalState.ApartmentRented;
                    RentAppartment();
                }
                else
                {
                    Output("Sorry, you were not approved");
                    rentalState = RentalState.Waiting;
                }
                return;
            }

            BadStateResponse();
        }
 public RentalMethods( int numberOfApartments )
 {
     rentalState = RentalState.Waiting;
     this.numberOfApartments = numberOfApartments;
 }
Esempio n. 10
0
 public TypeRentalState(RentalState value)
     : base(DataType.BookNo, (int)value)
 {
 }
Esempio n. 11
0
 public RentalMethods(int numberOfApartments)
 {
     rentalState             = RentalState.Waiting;
     this.numberOfApartments = numberOfApartments;
 }
Esempio n. 12
0
        /// <summary>
        /// Vytvoří entitu, vnitřně nic nekontroluje, je potřeba zkontrolovat předem.
        /// </summary>
        public static Renting Create(int customerId, DateTime startsAt, DateTime endsAt, RentalState state, string note, int[] items)
        {
            var renting = new Renting()
            {
                UserId          = customerId,
                StartsAt        = startsAt,
                EndsAt          = endsAt,
                State           = state,
                Note            = note,
                CancelationCode = StringExtensions.GetRandomString(25)
            };

            // Přidám do výpůjčky předměty.
            foreach (var i in items)
            {
                renting.RentingToItems.Add(new RentingToItem()
                {
                    ItemId = i
                });
            }

            return(renting);
        }
Esempio n. 13
0
 public static Renting Create(int customerId, DateTime startsAt, DateTime endsAt, RentalState state, string note, IEnumerable <Item> items)
 {
     return(Create(customerId, startsAt, endsAt, state, note, items.Select(i => i.Id).ToArray()));
 }