Exemplo n.º 1
0
        public async Task <int> Create(ProductCreateRequest request)
        {
            var product = new Entites.Product()
            {
                Name        = request.Name,
                Price       = request.Price,
                Description = request.Description,
                AppUser     = request.User,
            };

            if (request.ThumbnailImage != null)
            {
                product.ProductImages = new List <Entites.ProductImage>()
                {
                    new Entites.ProductImage()
                    {
                        DateCreated = DateTime.Now,
                        ImagePath   = await this.SaveFile(request.ThumbnailImage),
                        IsDefault   = true,
                    }
                };
            }

            context.Add(product);
            return(await context.SaveChangesAsync());
        }
Exemplo n.º 2
0
        public async Task <int> Create(ProductCreateRequest request)
        {
            var product = new Entites.Product()
            {
                Name        = request.Name,
                Price       = request.Price,
                Description = request.Description,
                AppUser     = request.User,
            };

            context.Add(product);
            return(await context.SaveChangesAsync());
        }