private Gem MapToDomain(GemEntity entity) { return(new Gem() { Id = entity.Id, Color = entity.Color, Price = entity.Price, Size = entity.Size }); }
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); }
public async Task UpdateGemAsync(GemEntity gemEntity) { _context.Update(gemEntity); await _context.SaveChangesAsync(); }