public async Task <ActionResult> Create([FromBody] MotherboardInsertDto motherboard) { _logger.LogForModelInsert(HttpContext); var insertResult = await _motherboardsService.CreateMotherboardAsync(motherboard); return(insertResult ? Json(motherboard) : ResponseResultsHelper.InsertError()); }
/// <inheritdoc/> public async Task <bool> CreateMotherboardAsync(MotherboardInsertDto motherboard) { var mappedMotherboard = _mapper.Map <MotherboardInsertDto, MotherboardEntity>(motherboard); var entityAlreadyExists = await _unitOfWorkHardwareAPI.MotherboardsRepository.AnyAsync(x => x.Equals(mappedMotherboard)); if (entityAlreadyExists) { return(false); } await _unitOfWorkHardwareAPI.MotherboardsRepository.AddAsync(mappedMotherboard); return(await _unitOfWorkHardwareAPI.SaveChangesAsync() > 0); }