Ejemplo n.º 1
0
        public int GetUserBalance(string userId)
        {
            // Get User Balance
            int debit  = Payments.Where(p => p.UserID == userId).Sum(p => (int?)p.Sum) ?? 0;
            int credit = UserChoices.Where(uc => uc.UserID == userId && uc.confirm).Sum(uc => (int?)uc.Menu.Price) ?? 0;

            return(debit - credit);
        }
Ejemplo n.º 2
0
        private void GetUserChoices(string user_token, string login_id)
        {
            try
            {
                this.Loading(true);

                var _parameter = new Dictionary <string, string>();
                {
                    _parameter.Add("sequence_no", this.user_curr_seqno.ToString());
                }

                var api = new ApiAsnycTask(this.Context, GetString(Resource.String.api_url) + "lotto/GetUserChoices", user_token);
                api.Execute(_parameter);

                api.SendFinish += (s, e) =>
                {
                    var _result = JsonConvert.DeserializeObject <ApiResult <List <UserChoice> > >(e.Json);
                    if (_result != null)
                    {
                        if (_result.success == true)
                        {
                            this.adapter.Clear();
                            this.adapter.AddAll(_result.result);
                            this.adapter.NotifyDataSetChanged();

                            var _choice = new UserChoices()
                            {
                                sequenceNo = this.user_curr_seqno,
                                loginId    = login_id,
                                choice     = _result.result
                            };

                            choice_list.RemoveAll(x => x.loginId == login_id && x.sequenceNo == this.user_curr_seqno);
                            choice_list.Add(_choice);

                            var app_cache = new AppPreferences(this.Context);
                            app_cache.UserChoiceNumbers = choice_list;

                            var tv_noting = this.rootView.FindViewById <TextView>(Resource.Id.tv_noting);
                            if (_result.result.Count == 0)
                            {
                                tv_noting.Visibility = ViewStates.Visible;
                            }
                        }
                        else
                        {
                            AppDialog.SNG.Alert(this.Context, _result.message);
                        }
                    }

                    this.Loading(false);
                };
            }
            catch (Java.Lang.Exception ex)
            {
                Log.Error(this.GetType().Name, ex.Message);
            }
        }
Ejemplo n.º 3
0
 protected bool Chosen(QuizProposal OneProposal)
 {
     if (UserChoices.TryGetValue(OneProposal.QuizItemId, out int proposalId))
     {
         // User already responded to this question
         // The choosen proposal of the user is proposalId
         // The correct proposal is OneProposal.Id
         return(OneProposal.Id == proposalId);
     }
     return(false);
 }
Ejemplo n.º 4
0
 private void StartQuiz()
 {
     foreach (Question question in Questions)
     {
         string choice = GameHelpers.GetAnswer("Question: ", question);
         UserChoices.Add(question.Answers.Find(answer => answer.ID.Equals(int.Parse(choice))));
         //UNDER CONSTRUCTION
         //IList<char> choices = ChooseAnswer(question;
         //var query = choices.SelectMany(
         //    choice => question.Answers.Where(
         //        answer => answer.ID.Equals(int.Parse(choice.ToString()))));
     }
 }
Ejemplo n.º 5
0
        protected void ProposalClicked(QuizProposal OneProposal)
        {
            // Check if user already selected a proposal
            var found = UserChoices.ContainsKey(OneProposal.QuizItemId);

            // Remove previously selected proposal (if any)
            if (found)
            {
                UserChoices.Remove(OneProposal.QuizItemId);
            }
            // Add current selected proposal of the user
            UserChoices.Add(OneProposal.QuizItemId, OneProposal.Id);
        }
Ejemplo n.º 6
0
        public virtual async Task ShowUserChoices(IDialogContext context, IAwaitable <IMessageActivity> activity)
        {
            var message            = await activity;
            var choiceOptions      = new UserChoices[] { UserChoices.CheckTicketStatus, UserChoices.OpenTicket, UserChoices.OrderItem };
            var choiceDescriptions = new string[] { "Check Ticket Status", "Open Ticket", "Order Equipment" };

            PromptDialog.Choice(
                context: context,
                resume: ChoiceReceivedAsync,
                prompt: "Please select an option",
                retry: "Please select from one of the displayed choices",
                promptStyle: PromptStyle.Auto,
                options: choiceOptions,
                descriptions: choiceDescriptions
                );
        }
Ejemplo n.º 7
0
        public virtual async Task ChoiceReceivedAsync(IDialogContext context, IAwaitable <UserChoices> activity)
        {
            UserChoices response = await activity;

            var choiceSelected = response.ToString();

            switch (choiceSelected)
            {
            case "CheckTicketStatus":
                context.Call <object>(new CheckTicketStatusDialog(), ChildDialogComplete);
                break;

            case "OpenTicket":
                context.Call <object>(new OpenTicketDialog(), ChildDialogComplete);
                break;
            }
        }
Ejemplo n.º 8
0
        /// <summary>
        /// Inform the user that he needs to enter some text,
        /// to send it to the Text Analytics API, so that he can get information on it.
        /// Then Wait for their input.
        /// - No text entered => get out of this service
        /// - text entered => starts service and then ask again when response received
        /// </summary>
        private static async void AskTextFromUser()
        {
            Console.WriteLine("You chosed, Text Analytics...");
            Console.WriteLine("Please enter your text (type nothing and press enter to get back to menu):");
            string input = Console.ReadLine();

            // Check if the user decides to get back
            if (string.IsNullOrWhiteSpace(input))
            {
                UserChoice = UserChoices.None;
            }
            else
            {
                // Start the application with the input text
                TextAnalyticsApp.TextToAnalyse = input;
                await TextAnalyticsApp.Start();
            }
        }
Ejemplo n.º 9
0
        // do not use, must refactor for use with CheckBoxes
        //public List<char> ChooseAnswer(Question question)
        //{
        //    List<char> choices;
        //    Console.Write("Enter your choice or choice(s) [if more than one just group it i.e. 123]: ");
        //    do
        //    {
        //        string input = Console.ReadLine();
        //        choices = input.ToList();
        //    } while (choices.Contains(',') || choices.Contains(' ') || !(choices.TrueForAll(key => char.IsDigit(key) ? !(int.Parse(key.ToString()) < 1 || int.Parse(key.ToString()) > question.Answers.Count) : false )));

        //    return choices;
        //}

        private string GradeQuiz()
        {
            Console.Clear();
            IList <Answer> correct = UserChoices.FindAll(answer => answer.IsCorrectAnswer);

            Correct = QuizGrader((double)correct.Count, (double)UserChoices.Count);

            GameHelpers.PrintSlow("Grading quiz");

            for (int i = 0; i < 5; i++)
            {
                Thread.Sleep(250);
                Console.Write(" .");
            }
            GameHelpers.PrintSlow(" Done!\nNow for the moment of truth, see results below\n");

            string result = string.Format("Result: {0} out of {1} correct: {2:P}", correct.Count, UserChoices.Count, Correct);

            return(result);
        }
Ejemplo n.º 10
0
    public void SendChoice()
    {
        UserChoices gm = GameObject.FindGameObjectWithTag("GameManager").GetComponent <UserChoices>();

        if (actual.Count == 1 && actual[0] == -1)
        {
            for (int i = 0; i < 3; i++)
            {
                gm.removeChoice(i);
            }
        }
        else
        {
            foreach (int ac in actual)
            {
                gm.addChoice(ac);
            }
        }
        actual.Clear();
        showChoiceWindow();

        GameObject.Find("ObjDisplay").GetComponent <ObjDisplay>().Refresh();
    }
Ejemplo n.º 11
0
        /// <summary>
        /// Inform the user that he needs to enter a valid image path
        /// Then wait for their input.
        /// - No path entered => get out of this service
        /// - path entered => starts the service and then ask again when response is received
        /// </summary>
        private static async void AskImagePathFromUser()
        {
            Console.WriteLine("You chose, Emotion...");

            // Valid examples
            // "http://s.eatthis-cdn.com/media/images/ext/543627202/happy-people-friends.jpg";
            // @"G:\MyPics\self\20161214_124159";

            Console.WriteLine("Please enter a valid image path (type nothing and press enter to get back to menu):");
            while (true)
            {
                DebugWarning("Enter image path loop");
                string input = Console.ReadLine();
                // If nothing entered, quit back to the menu
                if (string.IsNullOrWhiteSpace(input))
                {
                    UserChoice = UserChoices.None;
                    break;
                }

                // Try to set the ImagePath
                EmotionApp.ImagePath = input;

                // Make sure the image path is accepted by the application
                if (EmotionApp.ImagePath == null)
                {
                    // Starts the service when the image path provided is valid
                    await EmotionApp.Start();

                    break;
                }
                else
                {
                    Console.Write("This image path is not valid! Try again: ");
                }
            }
        }
Ejemplo n.º 12
0
        static void Main(string[] args)
        {
            UserChoices u = new UserChoices();

            u.Welcome();
        }