コード例 #1
0
 private Gem MapToDomain(GemEntity entity)
 {
     return(new Gem()
     {
         Id = entity.Id,
         Color = entity.Color,
         Price = entity.Price,
         Size = entity.Size
     });
 }
コード例 #2
0
        public int AddStoneToProduct(int productId, Gem gem)
        {
            var product = productRepository.FindById(productId);

            if (product.Gems.Count > 10)
            {
                throw new System.Exception("Number of gems should be lower or equal to 10");
            }

            var gemEntity = new GemEntity()
            {
                Color   = gem.Color,
                Price   = gem.Price,
                Size    = gem.Size,
                Product = product
            };

            gemRepository.Create(gemEntity);

            return(gemEntity.Id);
        }
コード例 #3
0
 public async Task UpdateGemAsync(GemEntity gemEntity)
 {
     _context.Update(gemEntity);
     await _context.SaveChangesAsync();
 }