public async Task <int> AddMenu(MenuInput input) { int id; Menu menu; if (input.Id == 0) { menu = new Menu() { MenuName = input.Name.Sluggify(), IsActive = input.IsActive, Id = input.Id, Order = _menuRepository.Count() + 1 }; id = await _menuManager.AddMenuAsync(menu); } else { menu = _menuRepository.Get(input.Id); menu.IsActive = input.IsActive; menu.MenuName = input.Name.Sluggify(); id = await _menuManager.AddMenuAsync(menu); } foreach (var inputAvailableLang in input.AvailableLangs) { if (string.IsNullOrEmpty(inputAvailableLang.DisplayText)) { continue; } if (inputAvailableLang.Id == 0) { await _menuManager.AddMenuContentAsync(MenuContent.CreateMenuContent(inputAvailableLang.Lang, inputAvailableLang.DisplayText, "", menu)); } else { var langContent = _menuContentRepository.Get(inputAvailableLang.Id); langContent.Text = inputAvailableLang.DisplayText; await _menuManager.AddMenuContentAsync(langContent); } } return(id); }