예제 #1
0
        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());
        }
예제 #2
0
 protected ApplicationViewData(Application application, IList <Category> categories, bool canGetSecretKey, IList <Guid> standards)
     : base(application)
 {
     Developer   = DeveloperViewData.Create(application.Developer);
     Permissions = ApplicationPersmissionsViewData.Create(application.Permissions);
     if (canGetSecretKey)
     {
         SecretKey = application.SecretKey;
     }
     categories  = categories.Where(x => application.Categories.Any(y => y.CategoryRef == x.Id)).ToList();
     Categories  = CategoryViewData.Create(categories);
     GradeLevels = application.GradeLevels.Select(x => x.GradeLevel).ToList();
     //if (application.ApplicationStandards != null && standards != null)
     //    Standards = CommonCoreStandardViewData.Create(
     //            standards.Where(x => application.ApplicationStandards.Any(y => y.StandardRef == x.Id))
     //                     .ToList());
 }
예제 #3
0
        public ActionResult UpdateInfo(Guid developerId, string name, string websiteLink, string email)
        {
            var user = MasterLocator.UserService.GetByLogin(email);

            if (user != null && user.Id != Context.UserId)
            {
                return(Json(new ChalkableException("User email already exists")));
            }

            var res = MasterLocator.DeveloperService.Edit(developerId, name, email, websiteLink, null);

            MasterLocator.UserTrackingService.ChangedEmail(Context.Login, email);
            if (Context.Role.LoweredName == CoreRoles.DEVELOPER_ROLE.LoweredName)
            {
                var timeZoneId = Context.DistrictTimeZone;
                var ip         = RequestHelpers.GetClientIpAddress(Request);
                MasterLocator.UserTrackingService.IdentifyDeveloper(res.Email, res.DisplayName,
                                                                    String.IsNullOrEmpty(timeZoneId) ? DateTime.UtcNow : DateTime.UtcNow.ConvertFromUtc(timeZoneId), timeZoneId, ip);
            }
            return(Json(DeveloperViewData.Create(res)));
        }
예제 #4
0
        public ActionResult DeveloperInfo(Guid developerId)
        {
            var developer = MasterLocator.DeveloperService.GetById(developerId);

            return(Json(DeveloperViewData.Create(developer)));
        }