public async Task <IActionResult> UpdateDomain(Guid id, [FromBody] DomainCreationOrUpdateRequest domainUpdateRequest) { if (domainUpdateRequest == null || string.IsNullOrWhiteSpace(domainUpdateRequest.Name)) { return(HandleBadRequest("A valid domain name needs to be provided.")); } try { Domain domain = await DomainService.UpdateDomain(id, domainUpdateRequest.Name); return(Ok(new DomainResponse(domain))); } catch (EntityNotFoundException exception) { return(HandleResourceNotFoundException(exception)); } catch (Exception exception) { return(HandleUnexpectedException(exception)); } }
public async Task <IActionResult> CreateDomain([FromBody] DomainCreationOrUpdateRequest domainCreationRequest) { if (domainCreationRequest == null || string.IsNullOrWhiteSpace(domainCreationRequest.Name)) { return(HandleBadRequest("A valid domain name needs to be provided.")); } try { Domain domain = await DomainService.CreateDomain(domainCreationRequest.Name); return(Created(GetNewResourceUri(domain.Id), new DomainResponse(domain))); } catch (EntityAlreadyExsistsException exception) { return(HandleResourceAlreadyExistsException(exception)); } catch (Exception exception) { return(HandleUnexpectedException(exception)); } }