コード例 #1
0
        private UserContext GetDeveloperContext(Developer developer)
        {
            Trace.Assert(developer.DistrictRef.HasValue);
            var user = developer.User;

            user.DistrictRef = developer.DistrictRef;
            user.LoginInfo   = new UserLoginInfo {
                Id = user.Id
            };
            user.District = DemoDistrictService.CreateDemoDistrict(developer.DistrictRef.Value);
            return(new UserContext(user, CoreRoles.DEVELOPER_ROLE, user.District, null, developer.Id, null, null));
        }
コード例 #2
0
ファイル: HomeController.cs プロジェクト: VijayMVC/chalkable
        public ActionResult Developer(Guid?currentApplicationId, bool?isPwdReset)
        {
            if (isPwdReset.HasValue && isPwdReset.Value)
            {
                ViewData[ViewConstants.REDIRECT_URL_KEY] = UrlsConstants.DEV_RESET_PASSWORD_URL;
            }

            var developer = MasterLocator.DeveloperService.GetById(MasterLocator.Context.UserId);

            PrepareJsonData(DeveloperViewData.Create(developer), ViewConstants.CURRENT_PERSON);
            var applications = MasterLocator.ApplicationService.GetApplicationsWithLive(developer.Id, null, null);

            ViewData[ViewConstants.AZURE_PICTURE_URL]       = PictureService.GetPicturesRelativeAddress();
            ViewData[ViewConstants.DEMO_AZURE_PICTURE_URL]  = PictureService.GeDemoPicturesRelativeAddress();
            ViewData[ViewConstants.SERVER_TIME]             = Context.NowSchoolTime.ToString(DATE_TIME_FORMAT);
            ViewData[ViewConstants.SCHOOL_YEAR_SERVER_TIME] = Context.NowSchoolYearTime.ToString(DATE_TIME_FORMAT);
            ViewData[ViewConstants.NEEDS_TOUR]                = false;
            ViewData[ViewConstants.ROLE_NAME]                 = Context.Role.LoweredName;
            ViewData[ViewConstants.CURRENT_USER_ROLE_ID]      = Context.RoleId;
            ViewData[ViewConstants.STUDENT_ROLE]              = CoreRoles.STUDENT_ROLE.Name;
            ViewData[ViewConstants.TEACHER_ROLE]              = CoreRoles.TEACHER_ROLE.Name;
            ViewData[ViewConstants.DISTRICT_ADMIN_ROLE]       = CoreRoles.DISTRICT_ADMIN_ROLE.Name;
            ViewData[ViewConstants.DISTRICT_ID]               = Context.UserId.ToString();
            ViewData[ViewConstants.DEMO_PICTURE_DISTRICT_REF] = DEMO_PICTURE_DISTRICT_REF;
            ViewData[ViewConstants.IS_DEMO_DISTRICT]          = true;
            if (Context.DistrictId.HasValue)
            {
                var district = DemoDistrictService.CreateDemoDistrict(Context.DistrictId.Value);
                var school   = DemoSchoolService.CreateMasterSchool(Context.DistrictId.Value);
                school.District = district;
                PrepareJsonData(ShortSchoolViewData.Create(school), ViewConstants.SCHOOL);
            }


            PrepareJsonData(BaseApplicationViewData.Create(applications), ViewConstants.APPLICATIONS);
            if (applications.Count > 0)
            {
                var app = currentApplicationId.HasValue ? applications.First(x => x.Id == currentApplicationId) : applications.Last();
                app = MasterLocator.ApplicationService.GetApplicationById(app.Id);
                var res = ApplicationController.PrepareAppInfo(MasterLocator, app, true, true);
                PrepareJsonData(res, ViewConstants.DEFAULT_APPLICATION, 6);
            }
            var ip = RequestHelpers.GetClientIpAddress(Request);

            MasterLocator.UserTrackingService.IdentifyDeveloper(developer.Email, developer.DisplayName, DateTime.UtcNow, "UTC", ip);
            return(View());
        }