public async Task Create_ShouldReturnCreated()
        {
            // Arrange
            int   constructionId             = 1;
            int   profileId                  = 3;
            short steelId                    = 3;
            var   constructionElementRequest = new ConstructionElementCreateRequest
            {
                ProfileId = profileId,
                SteelId   = steelId,
                Length    = 9,
            };
            string json        = JsonSerializer.Serialize(constructionElementRequest);
            var    httpContent = new StringContent(json, Encoding.UTF8, "application/json");
            var    endpoint    = $"/api/constructions/{constructionId}/elements";

            // Act
            var response = await _httpClient.PostAsync(endpoint, httpContent);

            // Assert
            Assert.Equal(HttpStatusCode.Created, response.StatusCode);
        }
Ejemplo n.º 2
0
 public ActionResult Create(
     int constructionId, ConstructionElementCreateRequest constructionElementRequest)
 {
     try
     {
         var constructionElementModel = _mapper.Map <ConstructionElement>(
             constructionElementRequest);
         _service.Create(
             constructionElementModel,
             constructionId,
             constructionElementRequest.ProfileId,
             constructionElementRequest.SteelId);
         return(Created(
                    $"construction-elements/{constructionElementModel.Id}", null));
     }
     catch (ArgumentNullException)
     {
         return(NotFound());
     }
     catch (ConflictException)
     {
         return(Conflict());
     }
 }