public void Models_StudentAvatarModel_Default_Instantiate_Get_Set_Should_Pass()
        {
            //arrange
            var result          = new StudentAvatarModel();
            var expectStudentId = "GoodStudentId1";

            // Act
            result.StudentId = expectStudentId;

            // Assert
            Assert.AreEqual(expectStudentId, result.StudentId, TestContext.TestName);
        }
        public ActionResult Avatar([Bind(Include =
                                             "AvatarId," +
                                             "StudentId," +
                                             "")] StudentAvatarModel data)
        {
            // If data passed up is not valid, go back to the Index page so the user can try again
            if (!ModelState.IsValid)
            {
                // Send back for edit, with Error Message
                return(View(data));
            }

            // If the Avatar Id is blank, error out
            if (string.IsNullOrEmpty(data.AvatarId))
            {
                return(RedirectToAction("Error", "Home"));
            }

            // If the Student Id is black, error out
            if (string.IsNullOrEmpty(data.StudentId))
            {
                return(RedirectToAction("Error", "Home"));
            }

            // Lookup the student id, will just replace the Avatar Id on it if it is valid
            var myStudent = Backend.StudentBackend.Instance.Read(data.StudentId);

            if (myStudent == null)
            {
                return(RedirectToAction("Error", "Home"));
            }

            // Set the Avatar ID on the Student and update in data store
            myStudent.AvatarId = data.AvatarId;
            Backend.StudentBackend.Instance.Update(myStudent);

            // Editing is done, so go back to the Student Portal
            return(RedirectToAction("Index", "Portal", new { Id = myStudent.Id }));
        }