示例#1
0
        //public ActionResult Student(int userId)
        //There is already a Controller.User, so I am using Student instead
        public ActionResult Student()
        {
            if (Session["User"] != null)
            {
                var userId  = ((Models.UserModel)Session["User"]).Id;
                var user    = userManager.User(userId);
                var classes = classManager
                              .ForUser(userId)
                              .Select(c => new MyWebApp.WebSite.Models.ClassModel
                {
                    Id          = c.Id,
                    Name        = c.Name,
                    Description = c.Description,
                    Price       = c.Price
                }).ToArray();

                var model = new UserViewModel
                {
                    User    = new MyWebApp.WebSite.Models.UserModel(user.Id, user.Name, user.Email, user.Password, user.IsAdmin),
                    Classes = classes
                };

                return(View(model));
            }
            else
            {
                return(Redirect("~/"));
            }
        }
示例#2
0
        public ActionResult Classes(int id)
        {
            var user    = userManager.User(id);
            var classes = classManager
                          .ForUser(id)
                          .Select(t => new cstructor.website.Models.ClassModel
            {
                Id          = t.Id,
                Name        = t.Name,
                Description = t.Description,
                Price       = t.Price
            }).ToArray();

            var model = new UserViewModel
            {
                User    = new cstructor.website.Models.UserModel(user.Id, user.Email, user.Password, user.IsAdmin),
                Classes = classes
            };

            return(View(model));
        }
        public ActionResult StudentClasses(int id)
        {
            var user = (Ziglearning.Website.Models.UserModel)Session["User"];

            var clas = classManager
                       .ForUser(id)
                       .Select(t =>
                               new Ziglearning.Website.Models.ClassModel(t.Id, t.Name, t.Description, t.Price)
            {
                Id          = t.Id,
                Name        = t.Name,
                Description = t.Description,
                Price       = t.Price
            }).ToArray();

            var model = new UserViewModel
            {
                User    = new Ziglearning.Website.Models.UserModel(user.Id, user.Name),
                Classes = clas
            };

            return(View(model));
        }