Пример #1
0
        public ActionResult Edit(Profile profile, string roles, HttpPostedFileBase image, bool isInstructor = false)
        {
            var userProfileToEdit =
                RepositoryFactory.UserRepository.Queryable.SingleOrDefault(
                    x => x.Identifier == CurrentUser.Identity.Name);

            if (userProfileToEdit == null)
            {
                Message = "You don't yet have a profile, please create one now";
                return(RedirectToAction("Create"));
            }

            UpdateModel(userProfileToEdit.Profile, "Profile", null, new[] { "image" });

            if (image != null)
            {
                userProfileToEdit.Profile.ImageUrl = CropAndSave(image, ProfilePictureWidth, ProfilePictureHeight);
            }

            userProfileToEdit.Roles.Clear();
            userProfileToEdit.Roles.Add(RepositoryFactory.RoleRepository.GetById(roles));

            RepositoryFactory.UserRepository.EnsurePersistent(userProfileToEdit);

            if (CurrentUser.IsInRole(RoleNames.Student))
            {
                // See if they requested to be an instructor
                if (isInstructor)
                {
                    // Notify admins
                    _notificationService.NotifyAdministrators("New instructor request",
                                                              profile.DisplayName + " (" + profile.Email + ") requested Instructor permissions.",
                                                              AuthenticatedUser,
                                                              ActionLinkHelper.ActionLink(Url.Action("GrantInstructorPermissions", "User", new { area = "Admin", id = CurrentUser.Identity.Name }), "Grant instructor permissions"));
                }
            }


            Message = "Your profile changes were successful";

            return(RedirectToAction("Edit"));
        }
Пример #2
0
        // GET: /Admin/RevokeBadge/Revoke/{badgeSubmission}

        /**
         * Revokes the badge previously granted by the given BadgeSubmission.
         **/
        public ActionResult Revoke(Guid id)
        {
            // Set the BadgeSubmission's state to unsubmitted and unapproved
            var badgeSubmission = RepositoryFactory.BadgeSubmissionRepository.GetNullableById(id);

            if (badgeSubmission == null)
            {
                return(HttpNotFound());
            }

            RepositoryFactory.BadgeSubmissionRepository.Remove(badgeSubmission);

            _notificationService.Notify(badgeSubmission.Creator, AuthenticatedUser,
                                        "Your badge has been revoked!",
                                        "Unforuntately, the \"" + badgeSubmission.Badge.Name + "\" badge has been revoked from you.",
                                        ActionLinkHelper.ActionLink(Url.Action("MyBadges", "Badge", new { area = string.Empty }), "View your badges"));

            Message = "The badge has been revoked.";
            return(RedirectToAction("Index"));
        }
Пример #3
0
        public ActionResult Approve(Guid id)
        {
            var badgeSubmission = RepositoryFactory.BadgeSubmissionRepository.GetNullableById(id);

            if (badgeSubmission == null)
            {
                return(HttpNotFound());
            }

            badgeSubmission.Approved  = true;
            badgeSubmission.AwardedOn = DateTime.UtcNow;

            _notificationService.Notify(badgeSubmission.Creator, AuthenticatedUser,
                                        "Your badge request has been approved",
                                        "Congratulations, you have been awarded the \"" + badgeSubmission.Badge.Name + "\" badge!",
                                        ActionLinkHelper.ActionLink(Url.Action("MyBadges", "Badge", new { area = string.Empty }), "View your badges"));
            RepositoryFactory.BadgeSubmissionRepository.EnsurePersistent(badgeSubmission);

            Message = "The badge request has been approved and a notification has been sent to the student.";
            return(RedirectToAction("Index"));
        }
Пример #4
0
        public ActionResult Approve(Guid id)
        {
            var badge = RepositoryFactory.BadgeRepository.GetNullableById(id);

            if (badge == null)
            {
                return(HttpNotFound());
            }

            badge.Approved = true;

            Message = "The badge was successfully approved and can now be earned by students";
            _notificationService.Notify(badge.Creator, AuthenticatedUser,
                                        "Your badge design has been approved",
                                        "Congratulations, your \"" + badge.Name + "\" badge was approved!",
                                        ActionLinkHelper.ActionLink(Url.Action("Earn", "Badge", new { area = string.Empty, id = badge.Id }), "Earn the badge"));


            RepositoryFactory.BadgeRepository.EnsurePersistent(badge);

            return(RedirectToAction("Index"));
        }