Example #1
0
        public async Task UpdateAsync(Guid id, UpdateCatRequest request)
        {
            var cat = await _catRepo.GetAsync(id);

            if (cat is null)
            {
                return;
            }

            cat.RouteName   = request.RouteName.Trim();
            cat.DisplayName = request.DisplayName.Trim();
            cat.Note        = request.Note.Trim();

            await _catRepo.UpdateAsync(cat);

            _cache.Remove(CacheDivision.General, "allcats");

            await _audit.AddAuditEntry(EventType.Content, AuditEventId.CategoryUpdated, $"Category '{id}' updated.");
        }
Example #2
0
        public async Task CreateAsync(UpdateCatRequest request)
        {
            var exists = _catRepo.Any(c => c.RouteName == request.RouteName);

            if (exists)
            {
                return;
            }

            var category = new CategoryEntity
            {
                Id          = Guid.NewGuid(),
                RouteName   = request.RouteName.Trim(),
                Note        = request.Note.Trim(),
                DisplayName = request.DisplayName.Trim()
            };

            await _catRepo.AddAsync(category);

            _cache.Remove(CacheDivision.General, "allcats");

            await _audit.AddAuditEntry(EventType.Content, AuditEventId.CategoryCreated, $"Category '{category.RouteName}' created");
        }