コード例 #1
0
        public async Task <IActionResult> OnPostUnregisterAsync()
        {
            ReferencedCalendarItem = await _repository.GetDocument(CalendarItemId);

            UseCaptcha = !User.Identity.IsAuthenticated && null != ReferencedCalendarItem && ReferencedCalendarItem.PublicListing;
            if (UseCaptcha)
            {
                RecaptchaResponse captchaValid = await _recaptcha.Validate(Request);

                if (!captchaValid.success)
                {
                    ModelState.AddModelError("reCaptcha", "Bitte das reCaptcha bestätigen.");
                }
            }
            if (!ModelState.IsValid)
            {
                ViewData["Message"] = "Schiefgegangen";
                return(Page());
            }
            Member        memberToUnregister;
            List <Member> members;

            if (null == ReferencedCalendarItem)
            {
                return(new NotFoundResult());
            }
            members            = (ReferencedCalendarItem.Members != null) ? new List <Member>(ReferencedCalendarItem.Members) : new List <Member>();
            memberToUnregister = members.Find(m => m.EMail == NewMember.EMail && m.Name == NewMember.Name);
            if (null == memberToUnregister)
            {
                ModelState.AddModelError("EMail", "E-Mail und Name stimmen mit keiner Anmeldung überein.");
                return(Page());
            }
            if (ReferencedCalendarItem.RegistrationKeyRequired)
            {
                RegistrationKey checkKey = ReferencedCalendarItem.RegistrationKeys.FirstOrDefault(r => r.Key == NewMember.RegistrationKey);
                if (null == checkKey)
                {
                    ModelState.AddModelError("RegistrationKey", "Der angegebene Registrierungsschlüssel ist nicht zulässig.");
                    return(Page());
                }
            }
            if (ModelState.IsValid)
            {
                members.RemoveAll(c => c.UniqueId == memberToUnregister.UniqueId);
                ReferencedCalendarItem.Members = members.OrderBy(m => m.RegistrationDate).ToArray();
                await _repository.UpsertDocument(ReferencedCalendarItem);

                ViewData["Message"] = "Abgemeldet";
                return(RedirectToPage("Index", new { permalink = ReferencedCalendarItem.UrlTitle, message = "Anmeldung gelöscht." }));
            }
            else
            {
                ViewData["Message"] = "Schiefgegangen";
                return(Page());
            }
        }
コード例 #2
0
        public async Task <IActionResult> OnPostAsync()
        {
            if (ModelState.IsValid)
            {
                if (String.IsNullOrEmpty(this.NewEvent.Host))
                {
                    this.NewEvent.Host = this.User.Identity.Name;
                }
                if (!String.IsNullOrEmpty(NewEvent.Id))
                {
                    CalendarItem existingCalendarItem = await _repository.GetDocument(NewEvent.Id);

                    if (null != existingCalendarItem)
                    {
                        NewEvent.Infos            = existingCalendarItem.Infos;
                        NewEvent.Members          = existingCalendarItem.Members;
                        NewEvent.RegistrationKeys = existingCalendarItem.RegistrationKeys;
                    }
                }
                await _repository.UpsertDocument(NewEvent);

                return(RedirectToPage("Index"));
            }
            else
            {
                Categories = await _categoryRepository.GetDocuments(d => d.ListName == EventCategoriesName);

                ViewData["Message"] = "Da stimmt was nicht.";
                return(Page());
            }
        }
コード例 #3
0
        public async void UpdateTags(string tags, string listName)
        {
            string[] tagList = tags.Split(',');
            foreach (string tag in tagList)
            {
                string trimmedTag = tag.Trim();
                if (!String.IsNullOrWhiteSpace(trimmedTag))
                {
                    string     logicalKey = listName + "-" + trimmedTag;
                    ArticleTag articleTag = await tagRepository.GetDocumentByKey(logicalKey);

                    if (null == articleTag)
                    {
                        articleTag            = new ArticleTag();
                        articleTag.LogicalKey = logicalKey;
                        articleTag.TagCount   = 1;
                        articleTag.Tag        = trimmedTag;
                    }
                    else
                    {
                        articleTag.TagCount += 1;
                    }
                    articleTag.ListName   = listName;
                    articleTag.TimeToLive = 3600 * 24 * 320; // Tags not used longer than one year can be deleted
                    await tagRepository.UpsertDocument(articleTag);
                }
            }
        }
コード例 #4
0
        public async Task <IActionResult> OnPostAddRegistrationKeyAsync()
        {
            ReferencedCalenderItem = await _calendarRepository.GetDocument(CalendarItemId);

            if (null == ReferencedCalenderItem)
            {
                return(new NotFoundResult());
            }
            if (ModelState.IsValid)
            {
                List <RegistrationKey> members = (ReferencedCalenderItem.RegistrationKeys != null) ? new List <RegistrationKey>(ReferencedCalenderItem.RegistrationKeys) : new List <RegistrationKey>();
                members.RemoveAll(c => c.Key == NewRegistrationKey.Key);
                members.Add(NewRegistrationKey);
                ReferencedCalenderItem.RegistrationKeys = members.ToArray();
                await _calendarRepository.UpsertDocument(ReferencedCalenderItem);

                return(RedirectToPage(new { documentid = CalendarItemId }));
            }
            else
            {
                ViewData["Message"] = "Schiefgegangen";
                return(Page());
            }
        }
コード例 #5
0
        // only on page level [Authorize(Policy = KnownRoles.PolicyIsCalendarCoordinator)]
        public async Task <IActionResult> OnGetDeleteContentItemAsync(string documentid, string contentitemid)
        {
            CalendarItem calendarItem = await _calendarRepository.GetDocument(documentid);

            if (calendarItem == null)
            {
                return(new NotFoundResult());
            }
            if (calendarItem.Infos != null)
            {
                List <ContentItem> infos = new List <ContentItem>(calendarItem.Infos);
                infos.RemoveAll(c => c.UniqueId == contentitemid);
                calendarItem.Infos = infos.ToArray();
                await _calendarRepository.UpsertDocument(calendarItem);
            }
            ViewData["Message"] = "Eintrag gelöscht";

            return(RedirectToPage());
        }
コード例 #6
0
        public async Task <IActionResult> OnPostAsync()
        {
            if (ModelState.IsValid)
            {
                IEnumerable <Shortcut> list = await repository.GetDocuments(s => s.Category == NewShortcut.Category && s.Nickname == NewShortcut.Nickname);

                Shortcut existingOne = list.FirstOrDefault();
                if (null != existingOne)
                {
                    NewShortcut.Id = existingOne.Id;
                }
                await repository.UpsertDocument(NewShortcut);

                ViewData["Message"] = "Shortcut gespeichert.";
                return(RedirectToPage("./Index"));
            }
            else
            {
                ViewData["Message"] = "Schiefgegangen";
                return(Page());
            }
        }
コード例 #7
0
        public async Task <IActionResult> OnPostAsync()
        {
            if (ModelState.IsValid)
            {
                IEnumerable <ListCategory> list = await repository.GetDocuments(s => s.ListName == Category.ListName && s.Category == Category.Category);

                ListCategory existingOne = list.FirstOrDefault();
                if (null != existingOne)
                {
                    Category.Id = existingOne.Id;
                }
                await repository.UpsertDocument(Category);

                ViewData["Message"] = "Kategorie gespeichert.";
                return(RedirectToPage("Kategorien"));
            }
            else
            {
                ViewData["Message"] = "Schiefgegangen";
                return(Page());
            }
        }
コード例 #8
0
        public async Task <IActionResult> OnPostAsync()
        {
            if (ModelState.IsValid)
            {
                CalendarItem calendarItem = await _repository.GetDocument(CalendarItemId);

                if (null == calendarItem)
                {
                    return(new NotFoundResult());
                }
                List <ContentItem> contentItems = (calendarItem.Infos != null) ? new List <ContentItem>(calendarItem.Infos) : new List <ContentItem>();
                contentItems.RemoveAll(c => c.UniqueId == AppointmentDetail.UniqueId);
                contentItems.Add(AppointmentDetail);
                calendarItem.Infos = contentItems.OrderBy(c => c.SortOrder).ToArray();
                await _repository.UpsertDocument(calendarItem);

                return(RedirectToPage("Index", new { permalink = calendarItem.UrlTitle }));
            }
            else
            {
                ViewData["Message"] = "Da stimmt was nicht.";
                return(Page());
            }
        }