Example #1
0
        public StepResult RunStep()
        {
            // Airports
            airportOnScreen.HeaderOutput();
            airportOnScreen.Output(repository.Airports);
            UserChoice userchoice = menu.Run();

            //это дублирующая логика только для слоя презентации
            if (userchoice == UserChoice.Add)
            {
                ProcessAdd();
            }

            //если юзер выбрал удалить
            if (userchoice == UserChoice.Delete)
            {
                ProcessDelete();
            }

            if (userchoice == UserChoice.Irrelevant)
            {
                ProcessIrrelevant();
            }

            if (userchoice == UserChoice.Cancel)
            {
                return(StepResult.Exit);
            }

            return(StepResult.Continue);
        }
        public async Task Help(IDialogContext context, LuisResult result)
        {
            QureyController qc = new QureyController();

            qc.PostQuestionOne(result.Query, result.TopScoringIntent.Intent, result.TopScoringIntent.Score.ToString(), "0");

            if (result.TopScoringIntent.Score < 0.4)
            {
                string ans = "";
                ans = qc.GetTrainedAnswer(result.Query);

                qc.PostAnswerOne(ans, result.TopScoringIntent.Intent);

                await context.PostAsync(ans);

                context.Wait(MessageReceived);
            }
            else
            {
                var options = new UserChoice[]
                {
                    UserChoice.SearchWiki, UserChoice.Weather, UserChoice.PopularMovie, UserChoice.SearchMovie,
                    UserChoice.Game, UserChoice.Train
                };
                var descriptions = new string[]
                {
                    "Search Wikipedia", "Get Weather Info", "Popular Movies", "Search for movie", "Play Game",
                    "Train Me"
                };
                PromptDialog.Choice <UserChoice>(context, ResumeAfterDialogChoiceSelection,
                                                 options, "You asked for help, well here are some of main topics you can find here...",
                                                 descriptions: descriptions);
            }
        }
 public ContentDialog1(ObservableCollection <Deck> userDeckList)
 {
     this.InitializeComponent();
     _deckList     = userDeckList;
     _selectedDeck = null;
     this.choice   = UserChoice.Nothing;
 }
Example #4
0
        static void Main(string[] args)
        {
            //Calculate the facotrial of a number
            // input
            int    UserNumber;
            long   Factorial;
            string UserChoice;

            //process
            //UserContinue loop
            UserChoice = "y";
            while (UserChoice.ToLower() == "y")
            {
                Console.WriteLine("Enter a number you would like the facotrial of (1-31)");
                UserNumber = int.Parse(Console.ReadLine());

                for (int i = UserNumber - 1; i > 0; i--)
                {
                    UserNumber = UserNumber * i;
                }
                Factorial = UserNumber;  // converts output to long

                //output
                Console.WriteLine($"The factorial is {Factorial}.");

                Console.WriteLine("Would you like to calculate another number? \"(y/n)\"");
                UserChoice = Console.ReadLine();
            }
        }
Example #5
0
        public async Task <UserChoice> PostUserChoice(UserChoice userChoice)
        {
            UserServices userServices = new UserServices();
            var          userchoice   = await userServices.PostUserChoice(userChoice);

            return(userchoice);
        }
        private async void ListView_ItemTapped(object sender, ItemTappedEventArgs e)
        {
            if (currentUser == 0)
            {
                await DisplayAlert("Warning", "Please Login First", "Ok");
            }
            else
            {
                var userOrgan = e.Item as OrganDetail;

                MainQuizIcons.IsVisible = true;
                QuizOptions.IsVisible   = false;


                UserChoice                = new UserChoice();
                UserChoice.UserID         = currentUser;
                UserChoice.OrganDetailID  = userOrgan.ID;
                HomeViewModel.UserChoices = await HomeViewModel.PostUserChoice(UserChoice);

                EditQuiz editQuiz = new EditQuiz();
                editQuiz.userId           = currentUser;
                editQuiz.organDetailId    = userOrgan.ID;
                HomeViewModel.UserChoices = await HomeViewModel.EditUserChoice(editQuiz);
            }
        }
Example #7
0
        public void View()
        {
            Console.Clear();
            Console.WriteLine("v2.0\nPlease, type the number\n1)Information about airplanes\n2)Add airplane\n3)Edit airplane\n4)Search airplane\n5)Delete airplane");
            Console.WriteLine();
            UserChoice userChoice = (UserChoice)int.Parse(Console.ReadLine());

            Console.WriteLine(userChoice);
            switch (userChoice)
            {
            case UserChoice.Information:
                Information();
                break;

            case UserChoice.AddRecords:
                AddRecord();
                break;

            case UserChoice.EditRecords:
                EditRecord();
                break;

            case UserChoice.SearchRecords:
                SearchRecord();
                break;

            case UserChoice.DeleteRecords:
                DeleteRecord();
                break;
            }
        }
        public async Task <ActionResult <UserChoice> > PostUserChoice(UserChoice userChoice)
        {
            if (!UserChoiceExists(userChoice.BasicOrganID, userChoice.UserID))

            {
                userChoice.IsFav = false;

                userChoice.organDetail = null;

                _context.UserChoices.Add(userChoice);
                await _context.SaveChangesAsync();

                return(CreatedAtAction("GetUserChoice", new { id = userChoice.ID }, userChoice));
            }
            var sd = await _context.UserChoices.Where(c => c.UserID == userChoice.UserID).FirstOrDefaultAsync();

            sd.OrganDetailID = userChoice.OrganDetailID;
            sd.organDetail   = null;
            sd.BasicOrganID  = userChoice.BasicOrganID;


            _context.Entry(sd).State = EntityState.Modified;
            await _context.SaveChangesAsync();

            return(sd);
        }
Example #9
0
        public IHttpActionResult Post(UserChoice userChoice)
        {
            if (userChoice.UserID == null)
            {
                userChoice.UserID = User.Identity.GetUserId();
                Validate(userChoice);
            }

            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            Menu menu    = db.Menus.First(m => m.Id == userChoice.MenuId);
            int  balance = db.GetUserBalance(userChoice.UserID);

            if (balance >= menu.Price)
            {
                db.UserChoices.Add(userChoice);
                db.SaveChanges();
            }
            else
            {
                return(BadRequest("Not enough money"));
            }

            return(CreatedAtRoute("Get", new { id = userChoice.Id }, userChoice));
        }
Example #10
0
        public IHttpActionResult Put(int id, UserChoice userChoice)
        {
            if (!ModelState.IsValid || id != userChoice.Id)
            {
                return(BadRequest(ModelState));
            }


            if (!CheckUserChoise(userChoice))
            {
                return(BadRequest("Not enough money"));
            }

            userChoice.Menu            = null;
            db.Entry(userChoice).State = EntityState.Modified;
            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!UserChoiceExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
Example #11
0
        static void Main(string[] args)
        {
            PromptHandlerClass promptHandler = new PromptHandlerClass();

            while (true)
            {
                UserChoice selection = promptHandler.PromptSelection();

                switch (selection)
                {
                case UserChoice.Exit:
                    return;

                case UserChoice.Range:
                    MainLoop(
                        promptHandler.PromptNumber("Select a minimum number"),
                        promptHandler.PromptNumber("Select a maximum number")
                        );
                    break;

                case UserChoice.SingleValue:
                    int choice = promptHandler.PromptNumber("Select a number");
                    MainLoop(choice, choice);
                    break;
                }
            }
        }
Example #12
0
        public UserChoice Run()
        {
            DisplayPrompt();
            string     UserInput  = Console.ReadLine();       //вот завели переменную
            UserChoice userChoice = IdentifyInput(UserInput); //вот положили ее в параметр

            return(userChoice);
        }
        //событие включениия панели выбора
        void ConfirmationPanel(UserChoice choise)
        {
            AudioManager.Instance.Play(StaticPrm.SOUND_CLICK_BUTTON);
            userChoise = choise;

            //событие отображения панели подтверждения
            ShowConfirmationPanel?.Invoke(true);
        }
        public void MenuOptions()
        {
            do
            {
                Console.Clear();
                AnsiConsole.Render(
                    new Panel(new Text($"\nHello and Welcome to Prague City Parking valet service!\nWhat would you like to do?\n\n1. Park a Vehicle\n\n2. Move a Vehicle\n\n3. Remove a Vehicle\n\n4. Search for a Vehicle\n\n5. View map of the parking lot\n\n6. View the parking price list\n\n\nPress Q to quit the program\n ").Centered())
                    .Expand()
                    .SquareBorder()
                    .Header($"[red]Main Menu| |{DateTime.Now}[/]")
                    .HeaderAlignment(Justify.Center));
                UserChoice = char.ToLower(Console.ReadKey(true).KeyChar);

                switch (UserChoice)
                {
                case '1':

                    AnsiConsole.Render(
                        new Panel(new Text($"\nWould you like to park an Mc or a Car:\n ").Centered())
                        .Expand()
                        .SquareBorder()
                        .Header("[red]Park A Vehicle[/]")
                        .HeaderAlignment(Justify.Center));
                    VehicleChoice = Console.ReadLine().ToLower();
                    switch (VehicleChoice)
                    {
                    case "mc":
                        Mc.ParkMC();
                        break;

                    case "car":
                        Car.ParkCar();
                        break;
                    }
                    break;

                case '2':
                    Vehicle.MoveVehicle();
                    break;

                case '3':
                    Vehicle.RemoveVehicle();
                    break;

                case '4':
                    Vehicle.SearchVehicle();
                    break;

                case '5':
                    Vehicle.ParkingLotMap();
                    break;

                case '6':
                    Vehicle.PriceList();
                    break;
                }
            } while (!UserChoice.Equals('q'));
        }
Example #15
0
 public HomeViewModel()
 {
     PopupContent = new ObservableCollection <PopupContent>();
     PopupItems   = new ObservableCollection <PopupItems>();
     _connection  = DependencyService.Get <ISQLiteDb>().GetConnection();
     Organs       = new ObservableCollection <OrganDetail>();
     _organs      = new ObservableCollection <OrganDetail>();
     UserChoices  = new UserChoice();
 }
        public HomePage()
        {
            InitializeComponent();
            HomeViewModel = new HomeViewModel();

            _connection = DependencyService.Get <ISQLiteDb>().GetConnection();

            UserChoice = new UserChoice();
        }
Example #17
0
        static void Main(string[] args)
        {
            //input
            int    UserNumber;
            string UserChoice;

            //Allow to play again
            UserChoice = "y";
            while (UserChoice.ToLower() == "y")
            {
                //body of loop

                //input validation
                while (true)
                {
                    try
                    {
                        Console.WriteLine("Welcome- Enter an integer");
                        UserNumber = int.Parse(Console.ReadLine());
                        break;
                    }
                    catch (FormatException e)
                    {
                        Console.WriteLine(e.Message);
                    }
                    catch (Exception f)
                    {
                        Console.WriteLine(f.Message);
                    }
                }

                //process
                Console.Write("Number".PadRight(10));
                Console.Write("Squared".PadRight(10));
                Console.WriteLine("Cubed");
                Console.Write("======".PadRight(10));
                Console.Write("=======".PadRight(10));
                Console.WriteLine("=====");
                for (int i = 1; i <= UserNumber; i++)
                {
                    //for(int j = 1; j<=1; j++) - Unessesary
                    {
                        //output
                        Console.Write(i.ToString().PadRight(10));
                        Console.Write((i * i).ToString().PadRight(10));
                        Console.WriteLine((i * i * i).ToString());
                    }
                }
                Console.WriteLine("Would you like to run again? \"(y/n)\"");
                UserChoice = Console.ReadLine();
            }

            //Continue upon user request loop


            //Console.ReadKey();
        }
Example #18
0
 public void ProcessInput(UserChoice choice)
 {
     while (choice != UserChoice.Quit)
     {
         switch (choice)
         {
         case UserChoice.ListItem;
             break;
         }
     }
Example #19
0
        public IHttpActionResult Get(int id)
        {
            UserChoice userChoice = db.UserChoices.Find(id);

            if (userChoice == null)
            {
                return(NotFound());
            }

            return(Ok(userChoice));
        }
Example #20
0
        ///////////////////////
        public async Task <UserChoice> PostUserChoice(UserChoice userChoice)
        {
            var serializedUser = JsonConvert.SerializeObject(userChoice);
            var content        = new StringContent(serializedUser, Encoding.UTF8, "application/json");
            var response       = await client.PostAsync($"/api/UserChoices", content);

            var result = await response.Content.ReadAsStringAsync();

            var userchoice = await Task.Run(() => JsonConvert.DeserializeObject <UserChoice>(result));

            return(userchoice);
        }
Example #21
0
        public IHttpActionResult Delete(int id)
        {
            UserChoice userChoice = db.UserChoices.Find(id);

            if (userChoice == null)
            {
                return(NotFound());
            }

            db.UserChoices.Remove(userChoice);
            db.SaveChanges();

            return(Ok(userChoice));
        }
        private UserChoice PromptWhatToDo()
        {
            Console.WriteLine("Choose what to do (enter number):");
            int num = 1;

            foreach (string availableChoiseName in Enum.GetNames(typeof(UserChoice)))
            {
                Console.WriteLine("{0} {1}", num++, availableChoiseName);
            }

            UserChoice chooise = Enum.Parse <UserChoice>(Console.ReadLine());

            return(chooise);
        }
        private void displayLogs(UserChoice choice)
        {
            Console.Clear();
            splitAndPrepareTheLogs();

            if (choice == UserChoice.AllLogs)
            {
                displayTheLogsInConsole(_allLogsPrepared);
            }
            else
            {
                displayTheLogsInConsole(_currentUserLogsPrepared);
            }
        }
Example #24
0
        public async Task <UserChoice> AddUserChoice(UserChoice userChoice)
        {
            try
            {
                var result = _context.UserChoices.AddAsync(userChoice);
                await _context.SaveChangesAsync();

                return(userChoice);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.InnerException.Message);
                return(null);
            }
        }
Example #25
0
        public static void Intro()

        {
            Console.WriteLine("Hello! Please enter the name of a file.");
            Console.ReadLine();
            string filename = Console.ReadLine();

            Console.WriteLine("Thank you! Your file" + filename + "will be used so you can save your information. Now what can I do for you? To list all books, please press '0'. To add a book, please press '1'. To save and exit, please press '2'");
            string     input  = Console.ReadLine();
            int        choice = int.Parse(input);
            UserChoice c      = (UserChoice)choice;

            switch (c)
            {
            case UserChoice.List:
                Console.WriteLine(c.ToString());
                break;

            case Temperature.Add:
                Console.WriteLine(c.ToString());
                break;

            case Temperature.Save:
                Console.WriteLine(t.ToString());
                break;

            default:
                Console.WriteLine("Invalid Input");
                break;
            }
            //string output;
            //if (num1 = 1)
            //{
            //    output = "you have selected list all books";
            //}
            //else if (num1 = 2)
            //{
            //    output = "you have selected add a book " ;
            //}
            //else if (num1 = 3)
            //{
            //    output = "your data has been saved! comeback soon...I get lonely.";
            //}
            //else
            //{
            //    Console.WriteLine(" Im sorry I cannot process your request. Please input either 1, 2, or 3.");
            //}
        }
        public static void Do()
        {
            string UserChoice;

            do
            {
                Console.WriteLine("*****Choose From The Below Options*****");
                Console.WriteLine("1.Store Teacher Data");
                Console.WriteLine("2.Retrive Teacher Data");
                Console.WriteLine("3.Update Teacher data");
                Console.WriteLine("4.Search By Id");
                int Choice = Convert.ToInt32(Console.ReadLine());
                switch (Choice)
                {
                case 1:
                    Console.WriteLine("*****Adding Data of a Teacher*****");
                    TeacherClass.AddTeacher();
                    break;

                case 2:
                    Console.WriteLine("*****Displaying Teachers List*****");
                    TeacherClass.GetTeacherData();
                    break;

                case 3:
                    Console.WriteLine("*****Updating Data of a Teacher*****");
                    Console.WriteLine("Input Id of the Teacher To Update... ");
                    TeacherClass.UpdateTeacher(Console.ReadLine());
                    break;

                case 4:
                    Console.WriteLine("*****Search Data of a Teacher*****");
                    Console.WriteLine("Input Id of the Teacher To Search... ");
                    TeacherClass.SearchByName(Console.ReadLine());
                    break;



                default:
                    Console.WriteLine("Incorrect Choice");
                    Environment.Exit(0);
                    break;
                }
                Console.WriteLine("Want to continue?(Type yes/no)");
                UserChoice = Console.ReadLine().ToLower();
            } while (UserChoice.Equals("yes"));
        }
Example #27
0
        public void whatsNext()
        {
            Console.WriteLine("What would you like to do next? \nType Return for menu. \nType Exit to leave.");
            string UserChoice;

            UserChoice = Console.ReadLine();
            switch (UserChoice.ToLower())
            {
            case "return":
                makeChoice();
                break;

            case "exit":
                Console.WriteLine("Thanks for visiting.  Come back Soon!");
                Console.ReadLine();
                break;
            }
        }
Example #28
0
        public ConfirmSaveResult ConfirmSaveChanges()
        {
            if (FileDirty)
            {
                string message = string.IsNullOrEmpty(OpenFileName) ?
                                 "Do you want to save the file?" :
                                 $"Save changes to {Path.GetFileName(OpenFileName)}?";

                UserChoice result = services.QueryUser(message, ProgramName);
                if (result == UserChoice.Yes)
                {
                    SaveFile_Impl();
                }
                else if (result == UserChoice.Cancel)
                {
                    return(ConfirmSaveResult.Cancel);
                }
            }

            return(ConfirmSaveResult.Ok);
        }
Example #29
0
        private void buttonSend_Click(object sender, EventArgs e)
        {
            var checkedButton = this.groupBox1.Controls.OfType <RadioButton>()
                                .FirstOrDefault(r => r.Checked);
            UserChoice userChoice = new UserChoice(checkedButton.Text);

            foreach (UserChoice answer in questions[currentQuestion].Answers)
            {
                if (answer.Equals(userChoice))
                {
                    score += questions[currentQuestion].Value;
                }
            }
            if (currentQuestion == questions.Count - 1)
            {
                TestController testController = new TestController();
                int            maxScore       = 0;
                foreach (QuestionModel question in questions)
                {
                    maxScore += question.Value;
                }
                double scr = Convert.ToDouble(score);
                scr   = scr / maxScore * 100;
                score = Convert.ToInt32(scr);
                testController.WriteTestResults(test, user, score);
                this.Close();
                Results resultsWindow = new Results(user, test, score);
                resultsWindow.Show();
            }
            else
            {
                currentQuestion++;
                this.Close();
                CurrentQuestionWindow currentQuestionWindow = new CurrentQuestionWindow(user, test, questions, currentQuestion, score);
                currentQuestionWindow.Show();
            }
        }
Example #30
0
        /// <summary>
        /// Check is posibe to confirm user order
        /// </summary>
        /// <param name="userChoice"></param>
        /// <returns>true if posible confirm order</returns>
        private bool CheckUserChoise(UserChoice userChoice)
        {
            bool       result    = false;
            UserChoice oldChoice = db.UserChoices.Where(uc => uc.Id == userChoice.Id).First();

            db.Entry(oldChoice).State = EntityState.Detached;
            Menu menu    = db.Menus.First(m => m.Id == userChoice.MenuId);
            int  balance = db.GetUserBalance(userChoice.UserID);


            if (User.IsInRole("Admin") || User.IsInRole("GlobalAdmin"))
            {
                if (userChoice.confirm && !oldChoice.confirm)
                {
                    balance = balance - menu.Price;
                    if (balance >= 0)
                    {
                        result = true;
                    }
                }

                if (!userChoice.confirm && oldChoice.confirm)
                {
                    result = true;
                }
            }

            if (userChoice.UserID == User.Identity.GetUserId() && !userChoice.confirm)
            {
                if (balance >= menu.Price)
                {
                    result = true;
                }
            }

            return(result);
        }