Пример #1
0
        public static int GetPersonId()
        {
            Person person = new Person();
            int    id     = -1;

            OutputService.DisplayConsole("Are you registered");
            NoYes     input     = (NoYes)InputService.GetValidatedUserChoice(new NoYes());
            DBService dbService = new DBService();

            switch (input)
            {
            case NoYes.No:

                OutputService.DisplayConsole("Write your name");
                person.PersonName = StringValidation.ValidateLength(MAX_LENGTH_RESPONSIBLE);
                OutputService.DisplayConsole("Enter your phone number (ex. 0991231212, 099-123-12-12, +1-099-123-12-12)");
                person.PhoneNumber = StringValidation.ValidatePhone();
                id = dbService.CreatePerson(person);
                dbService.Dispose();
                return(id);

            case NoYes.Yes:
                while (dbService.PersonExist(person) == null)
                {
                    OutputService.DisplayConsole("Write your name");
                    person.PersonName = StringValidation.ValidateLength(MAX_LENGTH_RESPONSIBLE);
                    OutputService.DisplayConsole("Enter your phone number (ex. 0991231212, 099-123-12-12, +1-099-123-12-12)");
                    person.PhoneNumber = StringValidation.ValidatePhone();
                    id = dbService.PersonExist(person).Id;
                }
                return(id);
            }
            return(-1);
        }
Пример #2
0
        public Service CreateServiceFromConsole()
        {
            Service newCustomService = new Service();

            OutputService.DisplayConsole("Enter Service Name: ");
            newCustomService.ServiceName = StringValidation.ValidateLength(MAX_LENGTH_SERVICE);

            OutputService.DisplayConsole("Enter Service Type (choose number): ");
            newCustomService.ServiceType = (ServiceType)InputService.GetValidatedUserChoice(new ServiceType());
            newCustomService.PersonId    = PersonHandler.GetPersonId();

            return(newCustomService);
        }