public async Task <Guid> UpdateAsync(Guid id, UpdateMenuRequest request) { var menu = await _menuRepo.GetAsync(id); if (menu is null) { throw new InvalidOperationException($"MenuEntity with Id '{id}' not found."); } var url = Helper.SterilizeLink(request.Url.Trim()); _logger.LogInformation($"Sterilized URL from '{request.Url}' to '{url}'"); menu.Title = request.Title.Trim(); menu.Url = url; menu.DisplayOrder = request.DisplayOrder; menu.Icon = request.Icon; menu.IsOpenInNewTab = request.IsOpenInNewTab; await _menuRepo.UpdateAsync(menu); await _audit.AddAuditEntry(EventType.Content, AuditEventId.MenuUpdated, $"Menu '{id}' updated."); return(menu.Id); }
public async Task <Guid> CreateAsync(UpdateMenuRequest request) { var uid = Guid.NewGuid(); var menu = new MenuEntity { Id = uid, Title = request.Title.Trim(), DisplayOrder = request.DisplayOrder, Icon = request.Icon, Url = request.Url, IsOpenInNewTab = request.IsOpenInNewTab }; if (request.SubMenus is { Length : > 0 })
public async Task <Guid> CreateAsync(UpdateMenuRequest request) { var uid = Guid.NewGuid(); var menu = new MenuEntity { Id = uid, Title = request.Title.Trim(), DisplayOrder = request.DisplayOrder, Icon = request.Icon, Url = request.Url, IsOpenInNewTab = request.IsOpenInNewTab }; await _menuRepo.AddAsync(menu); await _audit.AddAuditEntry(EventType.Content, AuditEventId.MenuCreated, $"Menu '{menu.Id}' created."); return(uid); }