コード例 #1
0
        public static ParkingLotInfo ModifyConfiguration(ParkingLotService service)
        {
            ParkingLotInfo parkingLot = new ParkingLotInfo();

            Console.WriteLine("Which record you wants to modify");
            Console.Write("Name of the parking lot : ");
            var id = service.HasParkingLot(Console.ReadLine());

            if (id != 0)
            {
                parkingLot.ParkingLotId = id;
                Console.Write("Enter vehical type : ");
                var parkingLotInfoId = service.GetParkingLotId(Console.ReadLine());
                if (parkingLotInfoId != 0)
                {
                    parkingLot.Id = parkingLotInfoId;
                    Console.Write("Rate : ");
                    Int32.TryParse(Console.ReadLine(), out int rate);
                    parkingLot.Rate = rate;
                    Console.Write("Space : ");
                    Int32.TryParse(Console.ReadLine(), out int space);
                    parkingLot.Space = space;
                    return(parkingLot);
                }
            }

            return(null);
        }
コード例 #2
0
        public static User AddNewUser(UserService userService, ParkingLotService service)
        {
            User user = new User();

            Console.WriteLine("Please enter user's details");
            Console.Write("Name : ");
            user.Name = Console.ReadLine();
            while (true)
            {
                Console.Write("UserName : "******"This username is assigned to someone please choose another ");
                }
            }
            Console.Write("Password : "******"Address : ");
            user.Address = Console.ReadLine();
            Console.WriteLine("User type for :\n               1. Admin\n               2. Manager");
            while (true)
            {
                Int32.TryParse(Console.ReadLine(), out int type);
                if (type == 1 || type == 2)
                {
                    if (type == 1)
                    {
                        user.Type = Convert.ToString(Role.Admin);
                    }
                    else if (type == 2)
                    {
                        user.Type = Convert.ToString(Role.Manager);
                        while (true)
                        {
                            Console.Write("Parking slot assign : ");
                            var id = service.HasParkingLot(Console.ReadLine());
                            if (id != 0)
                            {
                                user.ParkingLot = id;
                                break;
                            }
                            else
                            {
                                Console.WriteLine("Please enter correct parking lot name");
                            }
                        }
                    }
                    break;
                }
            }

            return(user);
        }
コード例 #3
0
        public static ParkingLotInfo SetupParkingConfiguration(ParkingLotService service)
        {
            ParkingLotInfo parkingLot = new ParkingLotInfo();

            Console.WriteLine("Enter new details in parking");
            Console.Write("Parking Name : ");
            var id = service.HasParkingLot(Console.ReadLine());

            if (id != 0)
            {
                parkingLot.ParkingLotId = id;
                Console.Write("Vehical type : ");
                parkingLot.VehicalType = Console.ReadLine();
                while (true)
                {
                    Console.Write("Space : ");
                    Int32.TryParse(Console.ReadLine(), out int space);
                    if (space > 0)
                    {
                        parkingLot.Space = space;
                        break;
                    }
                    else
                    {
                        Console.WriteLine("Please enter correct space");
                    }
                }
                while (true)
                {
                    Console.Write("Rate/Hr. : ");
                    Int32.TryParse(Console.ReadLine(), out int rate);
                    if (rate > 0)
                    {
                        parkingLot.Rate = rate;
                        break;
                    }
                    else
                    {
                        Console.WriteLine("Please enter correct rate");
                    }
                }
                return(parkingLot);
            }
            else
            {
                Console.WriteLine("This parking lot is not available");
                return(null);
            }
        }