public async Task <EntityDto> CreateOrUpdateTenantCategory(TenantCategoryEditDto input) { var isEdit = input.Id > 0; TenantCategory category; if (isEdit) { category = await _tenantCategoryManager.FindAsync(input.Id); if (category == null) { throw new UserFriendlyException(L("InvalidTenantCategory")); } } else { category = new TenantCategory(input.Title); } category.UpdateName(input.Title); category.UpdateIsActive(input.isActive); category.ClearSubCategories(); foreach (var item in input.SubCategories) { category.AddSubCategories(item.Title); } if (!isEdit) { await _tenantCategoryManager.CreateAsync(category); } await CurrentUnitOfWork.SaveChangesAsync(); return(new EntityDto(category.Id)); }
public Task CreateAsync(TenantCategory tenantCategory) { return(_repository.InsertAsync(tenantCategory)); }