Ejemplo n.º 1
0
        public async Task AddLog(string infoJson)
        {
            var deserializedInfo = JsonSerializer.Deserialize <InformationModel>(infoJson);
            var log = new Log
            {
                Time          = DateTime.UtcNow,
                Info          = deserializedInfo?.Value,
                InformationId = deserializedInfo?.Id
            };

            await _context.Logs.AddAsync(log);

            await _context.SaveChangesAsync();
        }
Ejemplo n.º 2
0
        public async Task <InformationModel> AddInfo(InformationModel informationModel)
        {
            var entity = await _context.Information.FindAsync(informationModel.Id);

            if (entity == null)
            {
                entity = _mapper.Map <Information>(informationModel);
                await _context.Information.AddAsync(entity);
            }
            else
            {
                _mapper.Map(informationModel, entity);
            }

            await _context.SaveChangesAsync();

            return(_mapper.Map <InformationModel>(entity));
        }