Example #1
0
        public async Task Create_ShouldReturnUnauthorized_WhenNoAccessToken()
        {
            // Arrange
            int   markId      = 1;
            short docTypeId   = 1;
            int   creatorId   = 1;
            int   inspectorId = 2;
            int   normContrId = 3;
            var   docRequest  = new DocCreateRequest
            {
                Name        = "NewCreate",
                Form        = 9.0f,
                TypeId      = docTypeId,
                CreatorId   = creatorId,
                InspectorId = inspectorId,
                NormContrId = normContrId,
                ReleaseNum  = 9,
                NumOfPages  = 9,
                Note        = "NewCreate",
            };
            string json        = JsonSerializer.Serialize(docRequest);
            var    httpContent = new StringContent(json, Encoding.UTF8, "application/json");
            var    endpoint    = $"/api/marks/{markId}/docs";

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

            // Assert
            Assert.Equal(HttpStatusCode.Unauthorized, response.StatusCode);
        }
Example #2
0
        public ActionResult Create(
            int markId, [FromBody] DocCreateRequest docRequest)
        {
            var docModel = _mapper.Map <Doc>(docRequest);

            try
            {
                _service.Create(
                    docModel,
                    markId,
                    docRequest.TypeId,
                    docRequest.CreatorId,
                    docRequest.InspectorId,
                    docRequest.NormContrId);
            }
            catch (ArgumentNullException)
            {
                return(NotFound());
            }
            return(Created(
                       $"docs/{docModel.Id}", null));
        }