Beispiel #1
0
        public async Task <Page> CreateIfNotExists(string name)
        {
            logger.LogInformation($"Searching for {name} page");
            var page = await pageRepository.GetEntityAsync(item => item.PageName == name);

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

            logger.LogInformation($"Page {name} not found, creating new");
            var newPage = new Page()
            {
                Likes    = 0,
                PageName = name
            };

            return(await pageRepository.CreateAsync(newPage));
        }