public IBeepSpeakers(SpeakerBase speaker, Action <SpeakerBase> enableBeeping)
 {
     Contract.Requires(speaker != null);
     Contract.Requires(enableBeeping != null);
     Contract.Ensures(
         _speaker != null &&
         _speaker == speaker);
     Contract.Ensures(
         _enableBeeping != null &&
         _enableBeeping == enableBeeping);
     _speaker       = speaker;
     _enableBeeping = enableBeeping;
 }
 public void UpdateSpeaker(SpeakerBase speaker, int userId)
 {
     Requires.NotNull(speaker);
     Requires.NotNull(speaker.ConferenceId);
     Requires.NotNull(speaker.UserId);
     speaker.LastModifiedByUserID = userId;
     speaker.LastModifiedOnDate   = DateTime.Now;
     using (var context = DataContext.Instance())
     {
         var rep = context.GetRepository <SpeakerBase>();
         rep.Update("SET Company=@0, Sort=@1, CreatedByUserID=@2, CreatedOnDate=@3, LastModifiedByUserID=@4, LastModifiedOnDate=@5, Url=@6, Description=@7, DescriptionShort=@8 WHERE ConferenceId=@9 AND UserId=@10",
                    speaker.Company, speaker.Sort, speaker.CreatedByUserID, speaker.CreatedOnDate, speaker.LastModifiedByUserID, speaker.LastModifiedOnDate, speaker.Url, speaker.Description, speaker.DescriptionShort, speaker.ConferenceId, speaker.UserId);
     }
 }
 public void AddSpeaker(SpeakerBase speaker, int userId)
 {
     Requires.NotNull(speaker);
     Requires.NotNull(speaker.ConferenceId);
     Requires.NotNull(speaker.UserId);
     speaker.CreatedByUserID      = userId;
     speaker.CreatedOnDate        = DateTime.Now;
     speaker.LastModifiedByUserID = userId;
     speaker.LastModifiedOnDate   = DateTime.Now;
     using (var context = DataContext.Instance())
     {
         context.Execute(System.Data.CommandType.Text,
                         "IF NOT EXISTS (SELECT * FROM {databaseOwner}{objectQualifier}Connect_Conference_Speakers " +
                         "WHERE ConferenceId=@0 AND UserId=@1) " +
                         "INSERT INTO {databaseOwner}{objectQualifier}Connect_Conference_Speakers (ConferenceId, UserId, Company, Sort, CreatedByUserID, CreatedOnDate, LastModifiedByUserID, LastModifiedOnDate, Url, Description, DescriptionShort) " +
                         "SELECT @0, @1, @2, @3, @4, @5, @6, @7, @8, @9, @10", speaker.ConferenceId, speaker.UserId, speaker.Company, speaker.Sort, speaker.CreatedByUserID, speaker.CreatedOnDate, speaker.LastModifiedByUserID, speaker.LastModifiedOnDate, speaker.Url, speaker.Description, speaker.DescriptionShort);
     }
 }
 public void DeleteSpeaker(SpeakerBase speaker)
 {
     DeleteSpeaker(speaker.ConferenceId, speaker.UserId);
 }
示例#5
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))));
        }
        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))));
        }