public async Task <ActionResult> Insert([FromBody] RandomAccessMemoryInsertDto randomAccessMemory)
        {
            _logger.LogForModelInsert(HttpContext);

            var insertResult = await _randomAccessMemoryService.CreateRandomAccessMemoryAsync(randomAccessMemory);

            return(insertResult ? Json(randomAccessMemory) : ResponseResultsHelper.InsertError());
        }
示例#2
0
        /// <inheritdoc/>
        public async Task <bool> CreateRandomAccessMemoryAsync(RandomAccessMemoryInsertDto randomAccessMemory)
        {
            var mappedRAM = _mapper.Map <RandomAccessMemoryInsertDto, RandomAccessMemoryEntity>(randomAccessMemory);

            var entityAlreadyExists = await _unitOfWorkHardwareAPI.RandomAccessMemoryRepository.AnyAsync(x => x.Equals(mappedRAM));

            if (entityAlreadyExists)
            {
                return(false);
            }

            await _unitOfWorkHardwareAPI.RandomAccessMemoryRepository.AddAsync(mappedRAM);

            return(await _unitOfWorkHardwareAPI.SaveChangesAsync() > 0);
        }