示例#1
0
        public async Task <bool> AddTrendingProduct(TrendingProduct trendingProduct)
        {
            await _context.AddAsync(trendingProduct);

            await _context.SaveChangesAsync();

            return(await Task.FromResult(true));
        }
示例#2
0
        public async Task <bool> UpdateTrendingProduct(TrendingProduct trendingProduct)
        {
            var trendingProductEntities = await _context.TrendingProducts
                                          .Where(tp => tp.CategoryName == trendingProduct.CategoryName).ToListAsync();

            foreach (var item in trendingProductEntities)
            {
                item.CategoryName = trendingProduct.CategoryName;
            }

            await _context.SaveChangesAsync();

            return(await Task.FromResult(true));
        }
        public async Task <Response <TrendingProduct> > UpdateTrendingProduct(TrendingProduct trendingProduct)
        {
            var httpResponse = new Response <TrendingProduct>();

            try
            {
                httpResponse.RequestState = true;
                httpResponse.ErrorState   = !await _productManager.UpdateTrendingProduct(trendingProduct);
            }
            catch (Exception ex)
            {
                httpResponse.ErrorState = true;
                httpResponse.ErrorList.Add(ex.Adapt <ApiException>());
            }
            return(httpResponse);
        }