public async Task <Response <CreateResult> > Handle(CreateSubDomain request) { var businessDomain = await _context.BusinessDomains.SingleOrDefaultAsync(x => x.Name.Equals(request.ParentDomainName)); if (businessDomain == null) { return(new Response <CreateResult>(CreateResult.DependentObjectNotFound)); } var businessSubDomain = new BusinessSubDomain() { Id = Guid.NewGuid(), Name = request.Name, Description = request.Description, ParentId = businessDomain.Id }; await _context.AddAsync(businessSubDomain); await _context.SaveChangesAsync(); return(new Response <CreateResult>(CreateResult.Created)); }
public async Task <Response <CreateResult> > Handle(CreateDomain request) { var businessDomainId = Guid.NewGuid(); var businessDomain = new BusinessDomain() { Id = businessDomainId, Name = request.Name, Description = request.Description, SubDomains = request.SubDomains.Select(x => new BusinessSubDomain() { Id = Guid.NewGuid(), Description = x.Description, Name = x.Name, ParentId = businessDomainId }).ToList() }; await _context.AddAsync(businessDomain); await _context.SaveChangesAsync(); return(new Response <CreateResult>(CreateResult.Created)); }