示例#1
0
        public UniversitiesViewModel GetUniversitiesViewModel()
        {
            var model = new UniversitiesViewModel();

            using (var db = new ErasmusDbContext())
            {
                model.Universities = db.Universities.ToList().Select(x => new UniversityView()
                {
                    Name        = x.Name,
                    Id          = x.Id,
                    Address     = x.Address,
                    Country     = x.Country,
                    ErasmusCode = x.ErasmusCode,
                    City        = x.City
                }).ToList();
            }

            return(model);
        }
        public ActionResult Universities()
        {
            UniversitiesViewModel model = _adminBusinessLogic.GetUniversitiesViewModel();

            return(View(model));
        }
示例#3
0
        public UniversitiesViewModel GetUniversitiesViewModel(string userId)
        {
            var model = new UniversitiesViewModel();

            using (var db = new ErasmusDbContext())
            {
                var store   = new UserStore <ErasmusUser>(db);
                var manager = new UserManager <ErasmusUser>(store);

                var currentUniAdmin = manager.Users.SingleOrDefault(x => x.Id == userId);
                if (currentUniAdmin == null)
                {
                    throw new FormValidationException("Invalid user");
                }

                var thisUserUniversityIds = db.UserPermissions.Where(x => x.UserId == userId).Select(x => x.UniversityId).ToList();

                var Univers = db.Universities.Where(x => thisUserUniversityIds.Contains(x.Id)).ToList();

                if (Univers.Any())
                {
                    model.Universities = Univers.Select(x => new UniversityView()
                    {
                        Name        = x.Name,
                        Id          = x.Id,
                        Address     = x.Address,
                        Country     = x.Country,
                        ErasmusCode = x.ErasmusCode,
                        City        = x.City
                    }).ToList();
                }

                return(model);
            }


            /*public ViewModels.Admin.StudySubjectsViewModel GetStudySubjectsViewModel(int ID)
             * {
             *  var model = new ViewModels.Admin.StudySubjectsViewModel();
             *
             *  using (var db = new ErasmusDbContext())
             *  {
             *      var thisUserUniversityIds = db.UserPermissions.Where(x => x.UniversityId == ID).Select(x => x.UniversityId).ToList();
             *
             *      var subjects = db.UserPermissions.Where(x => thisUserUniversityIds.Contains(x.UniversityId))
             *          .Select(x => x.User).Where(x => x.UniversityId != ID).ToList();
             *
             *
             *
             *      if (subjects.Any())
             *      {
             *          Name = x.Name,
             *          Id = x.Id,
             *          Credits = x.Credits,
             *          Language = x.Language,
             *          Evaluation = x.Evaluation,
             *          Semester = x.Semester,
             *          FieldOfStudyName = x.FieldOfStudy == null ? "Not assigned" : x.FieldOfStudy.Name
             *      }).ToList();
             *  }
             *  return model;
             *  }*/
        }
示例#4
0
        public ActionResult Universities()
        {
            UniversitiesViewModel model = _uniAdminBusinessLogic.GetUniversitiesViewModel(User.Identity.GetUserId());

            return(View(model));
        }
示例#5
0
 public MonkeysPage()
 {
     InitializeComponent();
     BindingContext = new UniversitiesViewModel();
 }