Exemple #1
0
        public async Task <IActionResult> OnGetAsync(string id)
        {
            var page = await _webpagesService.FindByIdAsync(id);

            if (page == null)
            {
                return(NotFound());
            }

            TitleDisplay = await TranslationsService.TranslateAsync("title");

            NameDisplay = await TranslationsService.TranslateAsync("name");

            TxtSeeArticles = await TranslationsService.TranslateAsync("Bekijk artikels");

            TxtSeeLinks = await TranslationsService.TranslateAsync("Bekijk links");

            PageTitle = await TranslationsService.TranslateAsync("Webpagina bijwerken");

            PageTitleLengthError = TranslationsService.TranslateErrorByDescriber(ErrorDescriberConstants.StringLength, $"The field '{TitleDisplay}' must contain a minimum of {4} and a maximum of {30} characters.", TitleDisplay, 4.ToString(), 30.ToString());
            ViewData["PageId"]   = page.Id;

            Vm = new WebPageViewModel
            {
                Id    = page.Id,
                Name  = page.Name,
                Title = page?.Title
            };

            return(Page());
        }
Exemple #2
0
        public async Task <IActionResult> OnPostUpdateAsync()
        {
            var link = await _linksService.FindByIdAsync(Vm.LinkId);

            if (link == null)
            {
                return(NotFound());
            }

            var exists = await _linksService.ExistsAsync(Vm.Name);

            if (exists && !Vm.Name.CompleteTrimAndUpper().Equals(link.UniqueNameIdentifier))
            {
                ModelState.AddModelError(string.Empty, TranslationsService.TranslateErrorByDescriber(ErrorDescriberConstants.NameDuplicate, $"The name {Vm.Name} is already taken.", Vm.Name));
                return(await OnGetAsync(link.Id));
            }

            link.Name = Vm?.Name;
            link.Url  = Vm?.Url;

            var result = await _linksService.UpdateAsync(link);

            if (result.Successfull)
            {
                return(RedirectToPage("/WebPage/UpdateLink", new { id = link.Id }));
            }

            foreach (var err in result.Errors)
            {
                ModelState.AddModelError(string.Empty, err.Message);
            }

            return(await OnGetAsync(link.Id));
        }
        public async Task <IActionResult> OnGetAsync(string id)
        {
            var image = await _imagesService.FindByIdAsync(id);

            if (image == null)
            {
                return(NotFound());
            }

            PageTitle = await TranslationsService.TranslateAsync("images");

            TitleDisplay = await TranslationsService.TranslateAsync("title");

            ImageDisplay = await TranslationsService.TranslateAsync("image");

            TitleRequiredError = TranslationsService.TranslateErrorByDescriber(ErrorDescriberConstants.RequiredField, $"The field '{TitleDisplay}' is required.", TitleDisplay);
            TitleLengthError   = TranslationsService.TranslateErrorByDescriber(ErrorDescriberConstants.StringLength, $"The field '{TitleDisplay}' must contain a minimum of {4} and a maximum of {30} characters.", TitleDisplay, 4.ToString(), 30.ToString());

            ForeignKeyProperties = _imagesService.GetForeignKeyPropertiesToDto(image).ToList();

            ViewData["ImgId"] = id;
            ImageId           = id;

            Vm = new UpdateImageViewModel
            {
                Title = image.Name,
                Url   = image.Url
            };

            return(Page());
        }
Exemple #4
0
        public async Task <IActionResult> OnGetAsync(Guid id)
        {
            var link = await _linksService.GetAll().Include(l => l.Webpage).FirstOrDefaultAsync(l => l.Id == id);

            if (link == null)
            {
                return(NotFound());
            }
            ViewData["LinkId"] = link.Id;
            ViewData["PageId"] = link.Webpage.Id;

            NameDisplay = await TranslationsService.TranslateAsync("name");

            PageTitle = await TranslationsService.TranslateAsync("Update link");

            LinkNameRequiredError = TranslationsService.TranslateErrorByDescriber(ErrorDescriberConstants.RequiredField, $"The field '{NameDisplay}' is required.", NameDisplay);
            LinkNameLengthError   = TranslationsService.TranslateErrorByDescriber(ErrorDescriberConstants.StringLength, $"The field '{NameDisplay}' must contain a minimum of {4} and a maximum of {30} characters.", NameDisplay, 4.ToString(), 30.ToString());
            LinkUrlRequiredError  = TranslationsService.TranslateErrorByDescriber(ErrorDescriberConstants.StringLength, $"The field 'Url' must contain a minimum of {4} and a maximum of {200} characters.", "Url", 4.ToString(), 200.ToString());

            Vm = new LinkViewModel
            {
                LinkId = link.Id.ToString(),
                PageId = link.Webpage.Id,
                Name   = link?.Name,
                Url    = link.Url
            };

            return(Page());
        }
        public async Task <IActionResult> OnGetAsync()
        {
            PageTitle = await TranslationsService.TranslateAsync("Webpages");

            TxtAddWebpage = await TranslationsService.TranslateAsync("Add webpage");

            TitleDisplay = await TranslationsService.TranslateAsync("title");

            NameDisplay = await TranslationsService.TranslateAsync("name");

            TxtAddedOn = await TranslationsService.TranslateAsync("Toegevoegd op");

            PageNameRequiredError = TranslationsService.TranslateErrorByDescriber(ErrorDescriberConstants.RequiredField, $"The field '{NameDisplay}' is required.", NameDisplay);
            PageNameLengthError   = TranslationsService.TranslateErrorByDescriber(ErrorDescriberConstants.StringLength, $"The field '{NameDisplay}' must contain a minimum of {4} and a maximum of {30} characters.", NameDisplay, 4.ToString(), 30.ToString());
            PageTitleLengthError  = TranslationsService.TranslateErrorByDescriber(ErrorDescriberConstants.StringLength, $"The field '{TitleDisplay}' must contain a minimum of {4} and a maximum of {30} characters.", TitleDisplay, 4.ToString(), 30.ToString());

            Pages = await Service.GetAll().OrderBy(p => p.Name).Select(p => new WebpagesViewModel
            {
                Id              = p.Id,
                PageName        = $"{p.Name.SubstringMaxLengthOrGivenLength(0, 20)}",
                DateTimeCreated = $"{p.DateTimeCreated.Value.ToShortDateString()} - ({p.DateTimeCreated.Value.ToShortTimeString()})"
            }).ToListAsync();

            return(Page());
        }
        public async Task <IActionResult> OnPostVerifyNotExistsAsync()
        {
            var exists = await Service.ExistsAsync(Name);

            if (exists)
            {
                return(new JsonResult(TranslationsService.TranslateErrorByDescriber(ErrorDescriberConstants.NameDuplicate, $"The name '{Name}' is already taken.", Name)));
            }
            return(new JsonResult(true));
        }
        public async Task <ActionResult> OnGetAsync()
        {
            Vm = new IndexViewModel {
                UsersFound = new List <UserDto>()
            };

            PageTitle = await TranslationsService.TranslateAsync("Gebruikers");

            TxtUserName = await TranslationsService.TranslateAsync("username");

            TxtRequiredUserName = TranslationsService.TranslateErrorByDescriber(ErrorDescriberConstants.RequiredField, $"The field '{TxtUserName}' is required.", TxtUserName);
            TxtLengthUserName   = TranslationsService.TranslateErrorByDescriber(ErrorDescriberConstants.StringLength, $"The field '{TxtUserName}' must contain a minimum of {1} and a maximum of {100} characters.", TxtUserName, 1.ToString(), 100.ToString());

            return(Page());
        }
Exemple #8
0
        public async Task <IActionResult> OnGetAsync()
        {
            PageTitle = await TranslationsService.TranslateAsync("Gebruikers");

            TxtUserName = await TranslationsService.TranslateAsync("Username");

            TxtEmail = await TranslationsService.TranslateAsync("Email");

            TxtLanguage = await TranslationsService.TranslateAsync("Language");

            TxtPassword = await TranslationsService.TranslateAsync("Password");

            TxtConfirmPassword = await TranslationsService.TranslateAsync("Confirm Password");

            TxtProfilePicture = await TranslationsService.TranslateAsync("Profile picture");

            TxtSelectLanguage = await TranslationsService.TranslateAsync("Select a language.");

            TxtClickToAddProfPic = await TranslationsService.TranslateAsync("Click here to add a profile picture.");

            TxtRequiredUserName = TranslationsService.TranslateErrorByDescriber(ErrorDescriberConstants.RequiredField, $"The field '{TxtUserName}' is required.", TxtUserName);
            TxtRequiredEmail    = TranslationsService.TranslateErrorByDescriber(ErrorDescriberConstants.RequiredField, $"The field '{TxtEmail}' is required.", TxtEmail);
            TxtRequiredPassword = TranslationsService.TranslateErrorByDescriber(ErrorDescriberConstants.RequiredField, $"The field '{TxtPassword}' is required.", TxtPassword);
            TxtLengthUserName   = TranslationsService.TranslateErrorByDescriber(ErrorDescriberConstants.StringLength, $"The field '{TxtUserName}' must contain a minimum of {4} and a maximum of {50} characters.", TxtUserName, 4.ToString(), 50.ToString());
            TxtCompareError     = TranslationsService.TranslateErrorByDescriber(ErrorDescriberConstants.CompareFields, $"The field '{TxtConfirmPassword}' and the field '{TxtPassword}' do not match.", TxtConfirmPassword, TxtPassword);

            Input = new InputModel
            {
                Languages = new List <PickedLanguageDto>
                {
                    new PickedLanguageDto {
                        ShortLanguage = "NL", LongLanguage = "Nederlands"
                    },
                    new PickedLanguageDto {
                        ShortLanguage = "EN", LongLanguage = "English"
                    },
                    new PickedLanguageDto {
                        ShortLanguage = "FR", LongLanguage = "Français"
                    },
                    new PickedLanguageDto {
                        ShortLanguage = "DE", LongLanguage = "Deutsch"
                    },
                }
            };

            return(Page());
        }
Exemple #9
0
        public async Task <IActionResult> OnGetAsync()
        {
            ForeignKeyPropertyNames = _imagesService.GetForeignKeyProperties()
                                      .Select(fk => fk.Name).ToList();

            PageTitle = await TranslationsService.TranslateAsync("Create Image");

            TitleDisplay = await TranslationsService.TranslateAsync("title");

            ImageDisplay = await TranslationsService.TranslateAsync("image");

            TitleRequiredError = TranslationsService.TranslateErrorByDescriber(ErrorDescriberConstants.RequiredField, $"The field '{TitleDisplay}' is required.", TitleDisplay);
            TitleLengthError   = TranslationsService.TranslateErrorByDescriber(ErrorDescriberConstants.StringLength, $"The field '{TitleDisplay}' must contain a minimum of {2} and a maximum of {30} characters.", TitleDisplay, 2.ToString(), 30.ToString());
            FileRequiredError  = TranslationsService.TranslateErrorByDescriber(ErrorDescriberConstants.RequiredField, $"The field '{ImageDisplay}' is required.", ImageDisplay);

            return(Page());
        }
        public virtual async Task <IActionResult> OnGetAsync(Guid pageId)
        {
            var page = await _webPagesService.FindByIdAllIncludedAsync(pageId);

            if (page == null)
            {
                return(NotFound());
            }

            PageTitle = await TranslationsService.TranslateAsync("Links");

            TxtAddLink = await TranslationsService.TranslateAsync("Add Link");

            NameDisplay = await TranslationsService.TranslateAsync("name");

            LinkNameRequiredError = TranslationsService.TranslateErrorByDescriber(ErrorDescriberConstants.RequiredField, $"The field '{NameDisplay}' is required.", NameDisplay);
            LinkNameLengthError   = TranslationsService.TranslateErrorByDescriber(ErrorDescriberConstants.StringLength, $"The field '{NameDisplay}' must contain a minimum of {4} and a maximum of {30} characters.", NameDisplay, 4.ToString(), 30.ToString());
            LinkUrlRequiredError  = TranslationsService.TranslateErrorByDescriber(ErrorDescriberConstants.StringLength, $"The field 'Url' must contain a minimum of {4} and a maximum of {200} characters.", "Url", 4.ToString(), 200.ToString());
            TxtAddedOn            = await TranslationsService.TranslateAsync("Toegevoegd op");

            ViewData["PageId"] = page.Id;
            Vm = new LinksViewModel
            {
                PageId = page.Id
            };

            if (page.Links.Count > 0)
            {
                Vm.Links = page.Links.OrderBy(l => l.UniqueNameIdentifier).Select(l => new LinkDto
                {
                    Id              = l.Id,
                    Name            = l?.Name,
                    Url             = l?.Url,
                    DateTimeCreated = $"{l.DateTimeCreated?.ToShortDateString()} - ({l.DateTimeCreated?.ToShortTimeString()})"
                }).ToList();
            }

            return(Page());
        }