public async Task GetMembers()
        {
            var institutionalId = Context.Users.Single(u => u.Email.Equals(User.Identity.Name)).InstitutionId;

            var assignments = (await Context.GetAssignmentsAsync()).Where(a => a.InstitutionId.Equals(institutionalId)).ToList();

            foreach (var index in Selected)
            {
                if (index >= 0 && index < assignments.Count)
                {
                    SelectedAssignments.Add(
                        new AssignmentCard()
                    {
                        Index      = index,
                        Assignment = assignments[index]
                    });
                }
            }

            NonSelectedAssignments = assignments.Select((x, index) =>
                                                        new AssignmentCard()
            {
                Assignment = x,
                Index      = index
            }).Where(x => !Selected.Contains(x.Index)).ToList();
        }
Esempio n. 2
0
        /// <summary>
        /// See assignments for an topic, term or example
        /// </summary>
        /// <param name="message">The message object</param>
        private void SeeAssignments(MessageObject message)
        {
            try
            {
                if (message == null || (!message.IsTermDefinition && !message.IsTopicDefinition && !message.IsExample))
                {
                    WriteMessageToUser(Properties.Resources.please_select_a_term_or_example_first_before_using_this_command);
                    return;
                }

                List <Assignment> assignments = null;
                string            text        = null;

                // Term definition or example
                if (message.IsTermDefinition || message.IsExample)
                {
                    assignments = Entity.GetAssignments(message.Term.Id, null);
                    if (assignments.Any())
                    {
                        text = string.Format(Properties.Resources.there_are_for_this_term_this_is_the_first_assignment, assignments.Count);
                    }
                }
                // Topic definition
                else
                {
                    assignments = Entity.GetAssignments(null, message.Topic.Id);
                    if (assignments.Any())
                    {
                        text = string.Format(Properties.Resources.there_are_under_this_topic_this_is_the_first_assignment, assignments.Count);
                    }
                }

                // Check if there are any assignments
                if (assignments != null && assignments.Any())
                {
                    SelectedAssignments = assignments;
                    CurrentAssignment   = SelectedAssignments.FirstOrDefault();

                    AddBotMessages(new MessageObject[] {
                        new MessageObject(text),
                        new MessageObject(CurrentAssignment)
                    }.ToList());
                }
                else
                {
                    WriteMessageToUser(Properties.Resources.there_are_no_assignments_for_this);
                }
            }
            catch (Exception mes)
            {
                WriteMessageToUser(mes.Message);
            }
        }
Esempio n. 3
0
        /// <summary>
        /// See previous assignment
        /// </summary>
        private void SeePreviousAssignment()
        {
            if (CurrentAssignment == null)
            {
                WriteMessageToUser(Properties.Resources.you_have_not_started_any_assignments_yet);
                return;
            }

            if (SelectedAssignments.IndexOf(CurrentAssignment) != 0)
            {
                CurrentAssignment = SelectedAssignments[SelectedAssignments.IndexOf(CurrentAssignment) - 1];
                SeeCurrentAssignment();
            }
            else
            {
                WriteMessageToUser(Properties.Resources.there_are_no_previous_assignments);
            }
        }
Esempio n. 4
0
        /// <summary>
        /// See next assignment
        /// </summary>
        private void SeeNextAssignment()
        {
            if (CurrentAssignment == null)
            {
                WriteMessageToUser(Properties.Resources.you_have_not_started_any_assignments_yet);
                return;
            }

            if (SelectedAssignments != null && SelectedAssignments.Count > 1 && SelectedAssignments.IndexOf(CurrentAssignment) != SelectedAssignments.Count - 1)
            {
                CurrentAssignment = SelectedAssignments[SelectedAssignments.IndexOf(CurrentAssignment) + 1];
                SeeCurrentAssignment();
            }
            else
            {
                WriteMessageToUser(Properties.Resources.there_are_no_more_assignments);
            }
        }