Exemplo n.º 1
0
        public override async Task <CreateResponse> CreateItem(CreateRequest request, ServerCallContext context)
        {
            _logger.LogInformation($"Create Request Received with body: {JsonConvert.SerializeObject(request)}");

            var entity = new Item {
                Name = request.Name
            };
            await _demoDbContext.AddAsync(entity);

            await _demoDbContext.SaveChangesAsync();

            return(new CreateResponse {
                Id = entity.Id
            });
        }
Exemplo n.º 2
0
        public async Task <int> Add(Product entity)
        {
            await _context.AddAsync(entity);

            return(await _context.SaveChangesAsync());
        }