Exemplo n.º 1
0
        public ActionResult Edit(int conferenceId, int attendeeId)
        {
            if (!ConferenceModuleContext.Security.CanManage)
            {
                if (User.UserID != attendeeId)
                {
                    ConferenceModuleContext.ThrowAccessViolation();
                }
            }
            var attendee = _repository.GetAttendee(conferenceId, attendeeId);
            var dto      = new AttendeeDTO(attendee);

            DotNetNuke.Framework.ServicesFramework.Instance.RequestAjaxAntiForgerySupport();
            return(View(dto));
        }
Exemplo n.º 2
0
        public ActionResult Edit(int conferenceId, int speakerId)
        {
            if (!ConferenceModuleContext.Security.CanManage)
            {
                if (User.UserID != speakerId)
                {
                    ConferenceModuleContext.ThrowAccessViolation();
                }
            }
            var speaker = _repository.GetSpeaker(conferenceId, speakerId);
            var dto     = new SpeakerDTO(speaker);

            DotNetNuke.Framework.ServicesFramework.Instance.RequestAjaxAntiForgerySupport();
            return(View(dto));
        }
Exemplo n.º 3
0
        public ActionResult Submit(int conferenceId, int sessionId)
        {
            var session = _repository.GetSession(conferenceId, sessionId);

            if (session == null)
            {
                session = new Session()
                {
                    ConferenceId = conferenceId
                };
            }
            else
            {
                if (!session.UserIsAuthor(User.UserID))
                {
                    ConferenceModuleContext.ThrowAccessViolation();
                }
            }
            DotNetNuke.Framework.ServicesFramework.Instance.RequestAjaxAntiForgerySupport();
            return(View(session.GetSessionBase()));
        }
Exemplo n.º 4
0
        public HttpResponseMessage UpdateImage(int conferenceId, int id, UpdateImageDTO data)
        {
            if (!ConferenceModuleContext.Security.CanManage)
            {
                if (id != UserInfo.UserID)
                {
                    ConferenceModuleContext.ThrowAccessViolation();
                }
            }
            var attendee = AttendeeRepository.Instance.GetAttendee(conferenceId, id);
            var file     = ImageUtils.SaveUserProfilePic(PortalSettings.PortalId, id, data.Image, UserInfo.UserID);

            if (file != null)
            {
                attendee.PhotoFolder      = file.Folder;
                attendee.PhotoFilename    = file.FileName;
                attendee.PhotoContentType = file.ContentType;
                attendee.PhotoHeight      = file.Height;
                attendee.PhotoWidth       = file.Width;
            }
            return(Request.CreateResponse(HttpStatusCode.OK, attendee));
        }
Exemplo n.º 5
0
        public HttpResponseMessage UploadPicture(int conferenceId, int id)
        {
            HttpPostedFile postedFile  = HttpContext.Current.Request.Files["profilepic"];
            var            fileName    = System.IO.Path.GetFileName(postedFile.FileName).RemoveIllegalCharacters();
            var            extension   = System.IO.Path.GetExtension(fileName);
            var            contentType = "";

            switch (extension.ToLower())
            {
            case ".jpg":
                contentType = "image/jpg";
                break;

            case ".png":
                contentType = "image/png";
                break;

            default:
                return(ServiceError("Unsupported File Format"));
            }
            if (postedFile.ContentLength > 1000000)
            {
                return(ServiceError("File too big"));
            }
            if (!ConferenceModuleContext.Security.CanManage)
            {
                if (id != UserInfo.UserID)
                {
                    ConferenceModuleContext.ThrowAccessViolation();
                }
            }
            var user       = DotNetNuke.Entities.Users.UserController.GetUserById(PortalSettings.PortalId, id);
            var userFolder = DotNetNuke.Services.FileSystem.FolderManager.Instance.GetUserFolder(user);
            var file       = DotNetNuke.Services.FileSystem.FileManager.Instance.AddFile(userFolder, fileName, postedFile.InputStream, true, false, contentType, UserInfo.UserID);

            return(Request.CreateResponse(HttpStatusCode.OK, ""));
        }
Exemplo n.º 6
0
        public ActionResult Edit(int conferenceId, int attendeeId, AttendeeDTO attendee)
        {
            if (!ConferenceModuleContext.Security.CanManage)
            {
                if (User.UserID != attendeeId)
                {
                    ConferenceModuleContext.ThrowAccessViolation();
                }
            }
            AttendeeBase recordToUpdate = null;
            var          existingRecord = _repository.GetAttendee(conferenceId, attendeeId);
            var          modeAdd        = false;

            if (existingRecord == null)
            {
                recordToUpdate = new AttendeeBase()
                {
                    ConferenceId = conferenceId, UserId = attendeeId
                };
                modeAdd = true;
            }
            else
            {
                recordToUpdate = existingRecord.GetAttendeeBase();
            }
            recordToUpdate.ReceiveNotifications = attendee.ReceiveNotifications;
            recordToUpdate.Company = attendee.Company;
            if (modeAdd)
            {
                _repository.AddAttendee(recordToUpdate, User.UserID);
            }
            else
            {
                _repository.UpdateAttendee(recordToUpdate, User.UserID);
            }
            // Now the DNN side of things
            var dnnUser = UserController.GetUserById(PortalSettings.PortalId, attendeeId);

            if (dnnUser == null)
            {
                // create the user
                dnnUser = new UserInfo()
                {
                    PortalID = PortalSettings.PortalId, Username = attendee.Email, Email = attendee.Email, FirstName = attendee.FirstName, LastName = attendee.LastName, DisplayName = attendee.DisplayName
                };
                UserController.CreateUser(ref dnnUser);
            }
            dnnUser.FirstName         = attendee.FirstName.Trim();
            dnnUser.Profile.FirstName = attendee.FirstName.Trim();
            dnnUser.LastName          = attendee.LastName.Trim();
            dnnUser.Profile.LastName  = attendee.LastName.Trim();
            dnnUser.DisplayName       = attendee.DisplayName.Trim();
            dnnUser.Email             = attendee.Email.Trim();
            // Handle the picture
            if (attendee.ProfilePic.filename != "")
            {
                IFileInfo file          = null;
                var       userFolder    = FolderManager.Instance.GetUserFolder(dnnUser);
                var       folderManager = FolderManager.Instance;
                file = FileManager.Instance.GetFile(userFolder, attendee.ProfilePic.filename);
                if (file != null)
                {
                    dnnUser.Profile.Photo = file.FileId.ToString();
                    var portalId = dnnUser.IsSuperUser ? -1 : PortalSettings.PortalId;
                    FixDnnController.SetUserProfileProperty(portalId, dnnUser.UserID, "Photo", file.FileId.ToString());
                }
            }
            if (!string.IsNullOrEmpty(attendee.Company))
            {
                dnnUser.Profile.SetProfileProperty("Company", attendee.Company);
                var portalId = dnnUser.IsSuperUser ? -1 : PortalSettings.PortalId;
                FixDnnController.SetUserProfileProperty(portalId, dnnUser.UserID, "Company", attendee.Company);
            }
            UserController.UpdateUser(PortalSettings.PortalId, dnnUser);
            // DotNetNuke.Common.Utilities.DataCache.ClearCache();
            if (GetRouteParameter() == "home")
            {
                return(ReturnRoute("Home", "Index", "refreshcache=1"));
            }
            else
            {
                return(ReturnRoute(attendee.ConferenceId, View("View", _repository.GetAttendee(attendee.ConferenceId, attendee.UserId))));
            }
        }
Exemplo n.º 7
0
        public ActionResult Edit(int conferenceId, int attendeeId, AttendeeDTO attendee)
        {
            if (!ConferenceModuleContext.Security.CanManage)
            {
                if (User.UserID != attendeeId)
                {
                    ConferenceModuleContext.ThrowAccessViolation();
                }
            }
            AttendeeBase recordToUpdate = null;
            var          existingRecord = _repository.GetAttendee(conferenceId, attendeeId);
            var          modeAdd        = false;

            if (existingRecord == null)
            {
                recordToUpdate = new AttendeeBase()
                {
                    ConferenceId = conferenceId, UserId = attendeeId
                };
                modeAdd = true;
            }
            else
            {
                recordToUpdate = existingRecord.GetAttendeeBase();
            }
            recordToUpdate.ReceiveNotifications = attendee.ReceiveNotifications;
            recordToUpdate.Company = attendee.Company;
            if (modeAdd)
            {
                _repository.AddAttendee(recordToUpdate, User.UserID);
            }
            else
            {
                _repository.UpdateAttendee(recordToUpdate, User.UserID);
            }
            // Now the DNN side of things
            var dnnUser = DotNetNuke.Entities.Users.UserController.GetUserById(PortalSettings.PortalId, attendeeId);

            if (dnnUser == null)
            {
                // create the user
                dnnUser = new UserInfo()
                {
                    PortalID = PortalSettings.PortalId, Username = attendee.Email, Email = attendee.Email, FirstName = attendee.FirstName, LastName = attendee.LastName, DisplayName = attendee.DisplayName
                };
                UserController.CreateUser(ref dnnUser);
            }
            dnnUser.FirstName   = attendee.FirstName.Trim();
            dnnUser.LastName    = attendee.LastName.Trim();
            dnnUser.DisplayName = attendee.DisplayName.Trim();
            dnnUser.Email       = attendee.Email.Trim();
            // Handle the picture
            if (attendee.ProfilePic.filename != "")
            {
                IFileInfo file          = null;
                var       userFolder    = FolderManager.Instance.GetUserFolder(dnnUser);
                var       folderManager = FolderManager.Instance;
                file = FileManager.Instance.GetFile(userFolder, attendee.ProfilePic.filename);
                dnnUser.Profile.Photo = file.FileId.ToString();
                if (file != null & attendee.ProfilePic.crop.points != null)
                {
                    System.IO.MemoryStream sizedContent = null;
                    using (var content = FileManager.Instance.GetFileContent(file))
                    {
                        sizedContent = ImageUtils.CreateImage(content, attendee.ProfilePic.crop.points, attendee.ProfilePic.crop.zoom, 200, file.Extension);
                    }
                    FileManager.Instance.AddFile(userFolder, file.FileName, sizedContent, true, false, file.ContentType);
                    sizedContent.Dispose();
                    ImageUtils.CreateThumbnails(file.FileId);
                }
            }
            if (!string.IsNullOrEmpty(attendee.Company))
            {
                dnnUser.Profile.SetProfileProperty("Company", attendee.Company);
            }
            UserController.UpdateUser(PortalSettings.PortalId, dnnUser);
            DotNetNuke.Entities.Profile.ProfileController.UpdateUserProfile(dnnUser);
            return(ReturnRoute(attendee.ConferenceId, View("View", _repository.GetAttendee(attendee.ConferenceId, attendee.UserId))));
        }
Exemplo n.º 8
0
        public ActionResult Edit(int conferenceId, int speakerId, SpeakerDTO speaker)
        {
            if (!ConferenceModuleContext.Security.CanManage)
            {
                if (User.UserID != speakerId)
                {
                    ConferenceModuleContext.ThrowAccessViolation();
                }
            }
            SpeakerBase recordToUpdate = null;
            var         existingRecord = _repository.GetSpeaker(conferenceId, speakerId);
            var         modeAdd        = false;

            if (existingRecord == null)
            {
                recordToUpdate = new SpeakerBase()
                {
                    ConferenceId = conferenceId, UserId = speakerId
                };
                modeAdd = true;
            }
            else
            {
                recordToUpdate = existingRecord.GetSpeakerBase();
            }
            recordToUpdate.Description      = speaker.Description;
            recordToUpdate.DescriptionShort = speaker.DescriptionShort;
            recordToUpdate.Url     = speaker.Url;
            recordToUpdate.Company = speaker.Company;
            if (modeAdd)
            {
                _repository.AddSpeaker(recordToUpdate, User.UserID);
            }
            else
            {
                _repository.UpdateSpeaker(recordToUpdate, User.UserID);
            }
            // Now the DNN side of things
            var dnnUser = DotNetNuke.Entities.Users.UserController.GetUserById(PortalSettings.PortalId, speakerId);

            if (dnnUser == null)
            {
                // create the user
            }
            dnnUser.FirstName   = speaker.FirstName.Trim();
            dnnUser.LastName    = speaker.LastName.Trim();
            dnnUser.DisplayName = speaker.DisplayName.Trim();
            dnnUser.Email       = speaker.Email.Trim();
            // Handle the picture
            if (speaker.ProfilePic.filename != "")
            {
                IFileInfo file          = null;
                var       userFolder    = FolderManager.Instance.GetUserFolder(dnnUser);
                var       folderManager = FolderManager.Instance;
                file = FileManager.Instance.GetFile(userFolder, speaker.ProfilePic.filename);
                dnnUser.Profile.Photo = file.FileId.ToString();
                if (file != null & speaker.ProfilePic.crop.points != null)
                {
                    System.IO.MemoryStream sizedContent = null;
                    using (var content = FileManager.Instance.GetFileContent(file))
                    {
                        sizedContent = ImageUtils.CreateImage(content, speaker.ProfilePic.crop.points, speaker.ProfilePic.crop.zoom, 200, file.Extension);
                    }
                    FileManager.Instance.AddFile(userFolder, file.FileName, sizedContent, true, false, file.ContentType);
                    sizedContent.Dispose();
                    ImageUtils.CreateThumbnails(file.FileId);
                }
            }
            DotNetNuke.Entities.Users.UserController.UpdateUser(PortalSettings.PortalId, dnnUser);
            DotNetNuke.Entities.Profile.ProfileController.UpdateUserProfile(dnnUser);
            return(ReturnRoute(speaker.ConferenceId, View("View", _repository.GetSpeaker(speaker.ConferenceId, recordToUpdate.UserId))));
        }
Exemplo n.º 9
0
        public ActionResult Edit(int conferenceId, int speakerId, SpeakerDTO speaker)
        {
            if (!ConferenceModuleContext.Security.CanManage)
            {
                if (User.UserID != speakerId)
                {
                    ConferenceModuleContext.ThrowAccessViolation();
                }
            }
            SpeakerBase recordToUpdate = null;
            var         existingRecord = _repository.GetSpeaker(conferenceId, speakerId);
            var         modeAdd        = false;

            if (existingRecord == null)
            {
                recordToUpdate = new SpeakerBase()
                {
                    ConferenceId = conferenceId, UserId = speakerId
                };
                modeAdd = true;
            }
            else
            {
                recordToUpdate = existingRecord.GetSpeakerBase();
            }
            recordToUpdate.Description      = speaker.Description;
            recordToUpdate.DescriptionShort = speaker.DescriptionShort;
            recordToUpdate.Url     = speaker.Url;
            recordToUpdate.Company = speaker.Company;
            if (modeAdd)
            {
                _repository.AddSpeaker(recordToUpdate, User.UserID);
            }
            else
            {
                _repository.UpdateSpeaker(recordToUpdate, User.UserID);
            }
            // Now the DNN side of things
            var dnnUser = DotNetNuke.Entities.Users.UserController.GetUserById(PortalSettings.PortalId, speakerId);

            if (dnnUser == null)
            {
                // create the user
            }
            dnnUser.FirstName   = speaker.FirstName.Trim();
            dnnUser.LastName    = speaker.LastName.Trim();
            dnnUser.DisplayName = speaker.DisplayName.Trim();
            dnnUser.Email       = speaker.Email.Trim();
            // Handle the picture
            if (speaker.ProfilePic.filename != "")
            {
                IFileInfo file          = null;
                var       userFolder    = FolderManager.Instance.GetUserFolder(dnnUser);
                var       folderManager = FolderManager.Instance;
                file = FileManager.Instance.GetFile(userFolder, speaker.ProfilePic.filename);
                if (file != null)
                {
                    dnnUser.Profile.Photo = file.FileId.ToString();
                    var portalId = dnnUser.IsSuperUser ? -1 : PortalSettings.PortalId;
                    FixDnnController.SetUserProfileProperty(portalId, dnnUser.UserID, "Photo", file.FileId.ToString());
                }
            }
            DotNetNuke.Entities.Users.UserController.UpdateUser(PortalSettings.PortalId, dnnUser);
            // DotNetNuke.Common.Utilities.DataCache.ClearCache();
            return(ReturnRoute(speaker.ConferenceId, View("View", _repository.GetSpeaker(speaker.ConferenceId, recordToUpdate.UserId))));
        }