/// <summary> /// 新增 /// </summary> /// <param name="menuRequestDto"></param> /// <returns></returns> public async Task <bool> CreateAsync(MenuRequestDto menuRequestDto) { var menu = menuRequestDto.MapToCreateEntity <MenuRequestDto, Menu>(); await MenuValidatorsFilter.DoValidationAsync(_menuRespository, menu, ValidatorTypeConstants.Create); return(await _menuRespository.InsertAsync(menu)); }
/// <summary> /// 新增菜单页面 /// </summary> /// <param name="input"></param> /// <returns></returns> public async Task AddMenuAysnc(MenuInput input) { if (input.ParentId == -1) { var entity = Map <MenuInput, Menu>(input); await _menuRespository.InsertAsync(entity); } else { var parentEntity = await _menuRespository.GetParentMenu(input.ParentId.Value); var entity = Map <MenuInput, Menu>(input); parentEntity.Children.Add(entity); await _menuRespository.UnitOfWork.SaveChangesAsync(); } }