コード例 #1
0
        public void Update(CampaignItemPresenter item)
        {
            if (item == null)
            {
                throw new ArgumentNullException("item");
            }

            this.repository.Update(this.mapper.Map(item));
        }
コード例 #2
0
        public virtual CampaignItemPresenter Map(CampaignItem item)
        {
            if (item == null)
            {
                throw new ArgumentNullException("item");
            }

            var presenter = new CampaignItemPresenter();

            presenter.Id            = item.Product.Id;
            presenter.IsFeatured    = item.IsFeatured;
            presenter.DiscountPrice = item.DiscountPrice != null ? item.DiscountPrice.Amount : new decimal?();
            presenter.ProductName   = item.Product.Name;
            presenter.UnitPrice     = item.Product.UnitPrice.Amount;

            return(presenter);
        }
コード例 #3
0
        public CampaignItem Map(CampaignItemPresenter presenter)
        {
            if (presenter == null)
            {
                throw new ArgumentNullException("presenter");
            }

            var unitPrice = new Money(presenter.UnitPrice, "DKK");

            Money discountPrice = null;

            if (presenter.DiscountPrice.HasValue)
            {
                discountPrice = new Money(presenter.DiscountPrice.Value, "DKK");
            }

            var product = new Product(presenter.Id, presenter.ProductName, unitPrice);

            return(new CampaignItem(product, presenter.IsFeatured, discountPrice));
        }