コード例 #1
0
        public async Task <IActionResult> CreateAsync([FromBody] EmployeeDomainModel model)
        {
            if (model == null)
            {
                return(BadRequest("The model that is passed in is empty. Model object is required."));
            }

            EmployeeDomainModel inserted;

            try { inserted = await _domain.InsertAsync(model).ConfigureAwait(false); }
            catch (Exception ex) { return(BadRequest(ex.InnerException)); }

            return(CreatedAtRoute("GetEmployee", new { id = inserted.EmployeeId }, inserted));
        }
コード例 #2
0
        public void InsertAsync_WithNullEmployeeParameter_ReturnArgumentNullException()
        {
            Func <Task> act = () => _domain.InsertAsync(null);

            act.Should().Throw <ArgumentNullException>();
        }