Inheritance: MonoBehaviour
        public ActionResult Context()
        {
            var ltiRequest = GetLtiRequestFromClaim();

            var consumer = _providerContext.Consumers.SingleOrDefault(c => c.Key.Equals(ltiRequest.ConsumerKey));

            if (consumer == null)
            {
                return(null);
            }

            var toolUser = new ToolUser
            {
                ConsumerName = consumer.Name,
                FirstName    = ltiRequest.LisPersonNameGiven,
                LastName     = ltiRequest.LisPersonNameFamily,
                ReturnUrl    = ltiRequest.LaunchPresentationReturnUrl,
                Roles        = ltiRequest.Roles
            };

            var roles = toolUser.Roles.Split(',');

            if (roles.Contains("Instructor"))
            {
                _ltiUserManager.AddToRole(User.Identity.GetUserId(), UserRoles.TeacherRole);
            }
            else if (roles.Contains("Learner"))
            {
                _ltiUserManager.AddToRole(User.Identity.GetUserId(), UserRoles.StudentRole);
            }

            return(PartialView("_ContextPartial", toolUser));
        }
    // Use this for initialization
    void Start()
    {
        this.rb2d           = this.GetComponent <Rigidbody2D> ();
        this.animator       = this.GetComponent <Animator> ();
        this.meleeAttacker  = this.GetComponent <MeleeAttacker> ();
        this.rangedAttacker = this.GetComponent <RangedAttacker> ();
        this.toolUser       = this.GetComponent <ToolUser> ();

        StartCoroutine(StartAnimations());
        // Give player starting items
        // this.inventory.Add("sword");
    }
    // Use this for initialization
    void Start()
    {
        this.rb2d           = this.GetComponent <Rigidbody2D> ();
        this.animator       = this.GetComponent <Animator> ();
        this.meleeAttacker  = this.GetComponent <MeleeAttacker> ();
        this.rangedAttacker = this.GetComponent <RangedAttacker> ();
        this.toolUser       = this.GetComponent <ToolUser> ();


        this.sword      = gameObject.AddComponent <AudioSource> ();
        this.sword.clip = Resources.Load("Sounds/SwordSwing1") as AudioClip;
        print(this.sword);

        // Give player starting items
        //this.inventory.Add("sword");
    }
Beispiel #4
0
        public ActionResult Context()
        {
            var ltiRequest = GetLtiRequestFromClaim();
            var consumer   = ProviderContext.Consumers.SingleOrDefault(c => c.Key.Equals(ltiRequest.ConsumerKey));

            if (consumer == null)
            {
                return(null);
            }

            var toolUser = new ToolUser
            {
                ConsumerName = consumer.Name,
                FirstName    = ltiRequest.LisPersonNameGiven,
                LastName     = ltiRequest.LisPersonNameFamily,
                ReturnUrl    = ltiRequest.LaunchPresentationReturnUrl,
                Roles        = ltiRequest.Roles
            };

            return(PartialView("_ContextPartial", toolUser));
        }
    // Use this for initialization
    void Start()
    {
        this.rb2d = this.GetComponent<Rigidbody2D> ();
        this.animator = this.GetComponent<Animator> ();
        this.meleeAttacker = this.GetComponent<MeleeAttacker> ();
        this.rangedAttacker = this.GetComponent<RangedAttacker> ();
        this.toolUser = this.GetComponent<ToolUser> ();

        StartCoroutine (StartAnimations());
        // Give player starting items
        // this.inventory.Add("sword");
    }
        public ActionResult Index()
        {
            List <string> tags        = new List <string>();
            List <string> collections = new List <string>();

            if (Request.IsAuthenticated)
            {
                //build user model
                ToolUser usr = new ToolUser(User.Identity.GetUserId(), User.Identity.Name, new List <Bookmark>());

                //get bookmarks
                using (SqlConnection conn = new SqlConnection(connectionString))
                {
                    conn.Open();
                    //get all bookmarks from db of user
                    string       commandText = "SELECT id, siteUrl, fileLoc FROM bookmarks b INNER JOIN userbookmarks ub ON ub.bookId = b.id WHERE ub.userId = @name";
                    SqlCommand   cmd         = new SqlCommand(commandText, conn);
                    SqlParameter name        = cmd.Parameters.Add("@name", SqlDbType.NVarChar);
                    name.Value = usr.id;

                    using (SqlDataReader reader = cmd.ExecuteReader())
                    {
                        while (reader.Read())
                        {
                            usr.bookmarks.Add(new Bookmark(String.Format("{0}", reader["siteUrl"]), Convert.ToString(reader["fileLoc"]), Convert.ToString(reader["id"])));
                        }
                    }
                    conn.Close();
                }

                //Get all the collections associated with this user from the server
                using (SqlConnection conn = new SqlConnection(connectionString))
                {
                    conn.Open();

                    string       commandText = "select label from collectionMarks where userId = @user";
                    SqlCommand   cmd         = new SqlCommand(commandText, conn);
                    SqlParameter user        = cmd.Parameters.Add("@user", SqlDbType.VarChar);

                    user.Value = User.Identity.GetUserId();


                    using (SqlDataReader reader = cmd.ExecuteReader())
                    {
                        while (reader.Read())
                        {
                            string label = String.Format("{0}", reader["label"]);
                            if (!collections.Contains(label))
                            {
                                collections.Add(label);
                            }
                        }
                    }
                }

                //Get all the tags associated with this user
                using (SqlConnection conn = new SqlConnection(connectionString))
                {
                    conn.Open();
                    string       commandText = "select tag from Tags t inner join BookmarkTags bmt on t.id = bmt.tagId where bmt.userId = @user";
                    SqlCommand   cmd         = new SqlCommand(commandText, conn);
                    SqlParameter user        = cmd.Parameters.Add("@user", SqlDbType.VarChar);
                    user.Value = User.Identity.GetUserId();

                    using (SqlDataReader reader = cmd.ExecuteReader())
                    {
                        while (reader.Read())
                        {
                            string tag = String.Format("{0}", reader["tag"]);
                            if (!tags.Contains(tag))
                            {
                                tags.Add(tag);
                            }
                        }
                    }
                }
                //display all bookmarks/bookmarks home
                return(View("MarkView", new MarkDisplayVM(usr.bookmarks, collections, tags)));
            }
            return(View());
        }
        public List <Bookmark> GetBookmarks(string collection = null, string tag = null)
        {
            //build user model
            ToolUser usr = new ToolUser(User.Identity.GetUserId(), User.Identity.Name, new List <Bookmark>());

            //get bookmarks
            List <Bookmark> bookmarks = new List <Bookmark>();

            using (SqlConnection conn = new SqlConnection(connectionString))
            {
                conn.Open();
                SqlCommand cmd = null;
                string     commandText;

                //get all bookmarks from db of user
                if (collection == null && tag == null)
                {
                    commandText = "SELECT id, siteUrl, fileLoc FROM bookmarks b INNER JOIN userbookmarks ub ON ub.bookId = b.id WHERE ub.userId = @name";
                    cmd         = new SqlCommand(commandText, conn);
                    SqlParameter name = cmd.Parameters.Add("@name", SqlDbType.NVarChar);
                    name.Value = usr.id;

                    using (SqlDataReader reader = cmd.ExecuteReader())
                    {
                        while (reader.Read())
                        {
                            bookmarks.Add(new Bookmark(String.Format("{0}", reader["siteUrl"]), Convert.ToString(reader["fileLoc"]), Convert.ToString(reader["id"])));
                        }
                    }
                }
                else if (collection != null && tag == null)
                {
                    commandText = "SELECT id, siteUrl, fileLoc FROM bookmarks b " +
                                  "INNER JOIN userbookmarks ub ON ub.bookId = b.id " +
                                  "INNER JOIN collectionMarks cm ON ub.bookId = cm.markId " +
                                  "WHERE ub.userId = @name AND cm.label = @collection";
                    cmd = new SqlCommand(commandText, conn);
                    SqlParameter name    = cmd.Parameters.Add("@name", SqlDbType.NVarChar);
                    SqlParameter collect = cmd.Parameters.Add("@collection", SqlDbType.VarChar);
                    name.Value    = usr.id;
                    collect.Value = collection;

                    using (SqlDataReader reader = cmd.ExecuteReader())
                    {
                        while (reader.Read())
                        {
                            bookmarks.Add(new Bookmark(String.Format("{0}", reader["siteUrl"]), Convert.ToString(reader["fileLoc"]), Convert.ToString(reader["id"])));
                        }
                    }
                }
                else if (collection == null && tag != null)
                {
                    commandText = "SELECT b.id, siteUrl, fileLoc FROM bookmarks b " +
                                  "INNER JOIN userbookmarks ub ON ub.bookId = b.id " +
                                  "INNER JOIN BookmarkTags bt ON ub.bookId = bt.markId " +
                                  "INNER JOIN Tags t ON t.id = bt.tagId " +
                                  "WHERE ub.userId = @name AND t.tag = @tag";
                    cmd = new SqlCommand(commandText, conn);
                    SqlParameter name     = cmd.Parameters.Add("@name", SqlDbType.NVarChar);
                    SqlParameter tagLabel = cmd.Parameters.Add("@tag", SqlDbType.VarChar);
                    name.Value     = usr.id;
                    tagLabel.Value = tag;

                    using (SqlDataReader reader = cmd.ExecuteReader())
                    {
                        while (reader.Read())
                        {
                            bookmarks.Add(new Bookmark(String.Format("{0}", reader["siteUrl"]), Convert.ToString(reader["fileLoc"]), Convert.ToString(reader["id"])));
                        }
                    }
                }


                //get all bookmarks in collection


                conn.Close();
            }
            return(bookmarks);
        }
    // Use this for initialization
    void Start()
    {
        this.rb2d = this.GetComponent<Rigidbody2D> ();
        this.animator = this.GetComponent<Animator> ();
        this.meleeAttacker = this.GetComponent<MeleeAttacker> ();
        this.rangedAttacker = this.GetComponent<RangedAttacker> ();
        this.toolUser = this.GetComponent<ToolUser> ();

        this.sword = gameObject.AddComponent<AudioSource> ();
        this.sword.clip = Resources.Load ("Sounds/SwordSwing1") as AudioClip;
        print (this.sword);

        // Give player starting items
        //this.inventory.Add("sword");
    }