public async Task <ActionResult> Create([FromBody] HardDriveDiskInsertDto hardDriveDisk) { _logger.LogForModelInsert(HttpContext); var insertResult = await _hardDriveDisksService.CreateHardDriveDiskAsync(hardDriveDisk); return(insertResult ? Json(hardDriveDisk) : ResponseResultsHelper.InsertError()); }
/// <inheritdoc/> public async Task <bool> CreateHardDriveDiskAsync(HardDriveDiskInsertDto hardDriveDisk) { var mappedHDD = _mapper.Map <HardDriveDiskInsertDto, HardDriveDiskEntity>(hardDriveDisk); var entityAlreadyExists = await _unitOfWorkHardwareAPI.HardDrivesRepository.AnyAsync(x => x.Equals(mappedHDD)); if (entityAlreadyExists) { return(false); } await _unitOfWorkHardwareAPI.HardDrivesRepository.AddAsync(mappedHDD); return(await _unitOfWorkHardwareAPI.SaveChangesAsync() > 0); }