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 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.º 3
0
        public async Task AddAttendeeAsynce(AttendeeDTO attendeeDTO)
        {
            var attendee = _mapper.Map <Attendee>(attendeeDTO);

            try
            {
                await _unitOfWork.AttendeeRepo.AddAttendeeAsynce(attendee);

                await _unitOfWork.SaveAsync();

                await _unitOfWork.CommitChangesAsync();
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Exemplo n.º 4
0
        public async Task <IActionResult> AddAttendee([FromBody] AttendeeDTO attendeeDTO)
        {
            try
            {
                if (attendeeDTO == null)
                {
                    return(BadRequest(new ApiResponse {
                        Status = false, Message = "Bad Request"
                    }));
                }

                await _attendeeService.AddAttendeeAsynce(attendeeDTO);
            }
            catch (Exception ex)
            {
                _logger.LogError(ex.Message, $"Failed to add Attendee: {DateTime.UtcNow.ToString("yyyy-MM-dd HH:mm:ss.fff")}");
            }
            _logger.LogInformation("Attendee was successfully added");
            return(Created("", new ApiResponse {
                Status = true, Message = "Successful"
            }));
        }
Exemplo n.º 5
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.º 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 = 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.º 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)));
 }