예제 #1
0
        public ActionResult SendEventInvite(int eventId, MemberTypes[] memberTypes, EmailViewModel email, bool fromUser)
        {
            if (CurrentMemberModel.AdminUserId == null)
            {
                return(RedirectToHome());
            }

            MemberSearchCriteria memberSearchCriteria = new MemberSearchCriteria(HomePage.Id)
            {
                Types = memberTypes
            };
            IReadOnlyCollection <MemberModel> members = _memberService.GetMembers(memberSearchCriteria, Umbraco);

            _memberService.SendMemberEmails(SiteSettings, members, email.Subject, email.Body, false,
                                            fromUser ? CurrentMemberModel.Email : null);
            _eventService.LogSentEventInvite(eventId, Umbraco);

            AddFeedback($"{members.Count} invites sent", true);

            return(RedirectToCurrentUmbracoPage());
        }
예제 #2
0
        public ActionResult ImportMemberPictures(IEnumerable <HttpPostedFileBase> files)
        {
            if (CurrentMemberModel.AdminUserId == null)
            {
                return(RedirectToHome());
            }

            List <string> notFound = new List <string>();
            List <string> updated  = new List <string>();

            IPublishedContent chapter = HomePage;

            IReadOnlyCollection <MemberModel> memberModels = _memberService.GetMembers(new MemberSearchCriteria(chapter.Id), Umbraco);

            foreach (HttpPostedFileBase file in files)
            {
                FileInfo    fileInfo    = new FileInfo(file.FileName);
                string      fullName    = fileInfo.Name.Substring(0, fileInfo.Name.Length - fileInfo.Extension.Length);
                MemberModel memberModel = memberModels.FirstOrDefault(x => x.FullName.Equals(fullName, StringComparison.OrdinalIgnoreCase));
                if (memberModel == null)
                {
                    notFound.Add(file.FileName);
                    continue;
                }

                IPublishedContent member = Members.GetById(memberModel.Id);

                UpdateMemberModel updateMemberModel = new UpdateMemberModel(member);
                updateMemberModel.UploadedPicture = file;

                _memberService.Update(member.Id, updateMemberModel, Umbraco);

                updated.Add(file.FileName);
            }

            if (notFound.Count > 0)
            {
                AddFeedback("Members not found: " + string.Join(", ", notFound), false);
            }

            if (updated.Count > 0)
            {
                AddFeedback("Members updated: " + string.Join(", ", updated), true);
            }

            return(RedirectToCurrentUmbracoPage());
        }