public async Task<IHttpActionResult> CreateFailureType(FailureTypeDto dto)
        {
            if ((await _faulureTypeRepository.GetFailureTypeByIdAsync(dto.Id)) != null)
                return BadRequest("ID:" + dto.Id + "已存在");

            var category = await _faulureTypeRepository.GetCategoryByIdAsync(dto.Category);
            if (category == null)
                return BadRequest("Invalid Categroy.");

            var ft = Mapper.Map<FailureTypeDto, FailureType>(dto);
            ft.Category = category;
            await _faulureTypeRepository.CerateFailureTypeAsync(ft);
            return StatusCode(HttpStatusCode.Created);
        }
        public async Task<IHttpActionResult> UpdateFailureType(FailureTypeDto dto)
        {
            if ((dto.Id == "") || (dto.Name == ""))
                return BadRequest("ID或名字不正确");
            var ft = await _faulureTypeRepository.GetFailureTypeByIdAsync(dto.Id);
            if (ft == null)
                return NotFound();
            if (dto.Category != ft.CategoryId)
                return BadRequest("不允许修改 Category");

            ft.IsEnabled = dto.IsEnabled;
            ft.Name = dto.Name;
            ft.Description = dto.Description;

            await _faulureTypeRepository.SaveAsync(ft);
            return StatusCode(HttpStatusCode.Created);
        }