Ejemplo n.º 1
0
        public async Task AddingDuplicateAirplaneSeatTypeReturnsDuplicateResult()
        {
            // Arrange
            AirplaneSeatType airplane = new AirplaneSeatType()
            {
                Name = "Business class", AirplaneId = 1
            };

            // Act
            AddResult addResult = await _airplaneService.AddAirplaneSeatTypeAsync(airplane);

            // Assert
            Assert.AreEqual(ResultTypes.Duplicate, addResult.ResultType);
        }
Ejemplo n.º 2
0
        public async Task <ActionResult> AddAirplaneSeatTypeAsync(int airplaneId, [FromBody] AirplaneSeatType seatType)
        {
            seatType.AirplaneId = airplaneId;

            BlAirplaneSeatType seatTypeBl = _mapper.Map <BlAirplaneSeatType>(seatType);

            AddResult addAddResult = await _airplaneService.AddAirplaneSeatTypeAsync(seatTypeBl);

            switch (addAddResult.ResultType)
            {
            case ResultTypes.Duplicate:
                return(BadRequest());

            case ResultTypes.NotFound:
                return(NotFound());
            }

            return(Ok(new { Id = addAddResult.ItemId }));
        }