예제 #1
0
 public async Task SaveCartCampaignAsync(CartCampaignModel cartCampaignModel, int cartId)
 {
     if (_dbContext.CartCampaigns.Count(cc => cc.CartId == cartId) > 0)
     {
         _dbContext.CartCampaigns.RemoveRange(_dbContext.CartCampaigns.Where(cc => cc.CartId == cartId)); //Remove old campaigns from cart
     }
     _dbContext.CartCampaigns.Add(cartCampaignModel);                                                     //Add new selected campaign
     await _dbContext.SaveChangesAsync();
 }
예제 #2
0
        public static CartCampaignModel MockCartCampaignModel()
        {
            CartCampaignModel cartCampaignModel = new CartCampaignModel()
            {
                DiscountAmount = 50,
                CampaignId     = MockCampaignModel().CampaignId,
                CartId         = MockCartModel().CartId
            };

            return(cartCampaignModel);
        }
예제 #3
0
 private async Task SaveCampaignAsync(CartDTO cart, CampaignDTO selectedCampaign, double discountAmount)
 {
     CartCampaignDTO cartCampaignDTO = new CartCampaignDTO
     {
         CartId         = cart.CartId,
         CampaignId     = selectedCampaign.CampaignId,
         DiscountAmount = discountAmount
     };
     CartCampaignModel cartCampaignModel = _mapper.Map <CartCampaignModel>(cartCampaignDTO);
     await _cartEFService.SaveCartCampaignAsync(cartCampaignModel, cart.CartId);
 }