Ejemplo n.º 1
0
        public void UpdateCigar(Library.Models.Cigar cigar)
        {
            _logger.LogInformation("Updating cigar with ID {cigarId}", cigar.Id);

            Cigar currentEntity = _dbContext.Cigar.Find(cigar.Id);
            Cigar newEntity     = Mapper.Map(cigar);

            _dbContext.Entry(currentEntity).CurrentValues.SetValues(newEntity);
        }
Ejemplo n.º 2
0
        public void AddCigar(Library.Models.Cigar cigar)
        {
            if (cigar.Id != 0)
            {
                _logger.LogWarning("Cigar to be added has an ID ({cigarId}) already: ignoring.", cigar.Id);
            }

            _logger.LogInformation($"Adding cigar");

            Cigar entity = Mapper.Map(cigar);

            entity.Id = 0;
            _dbContext.Add(entity);
        }