本文整理匯總了C#中Cart.Remove方法的典型用法代碼示例。如果您正苦於以下問題:C# Cart.Remove方法的具體用法?C# Cart.Remove怎麽用?C# Cart.Remove使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Cart
的用法示例。
在下文中一共展示了Cart.Remove方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: RemoveAlbumsFromCart
private void RemoveAlbumsFromCart(IEnumerable<Guid> productsToRemove, Cart cart)
{
foreach (
var product in productsToRemove.Select(productId => _albumRepository.FindBy(productId)).Where(product => product != null))
{
cart.Remove(product);
}
}
示例2: Generate
public void Generate(ChartResultParameter par)
{
DateTime begin = DateTime.Now;
HtmlTemplate index = new HtmlTemplate("index");
string articlesString = "", cancellationsString = "", depositsString = "";
string usersString = "";
double sum = 0.0;
result.Sales.Sort(par.SortOrder);
result.Cancellations.Sort(par.SortOrder);
index.Insert("datetime", DateTime.Now.ToString());
index.Insert("version", Administration.Properties.Resources.Version);
#region information
index.Insert("profile", chart.Profile.Name);
foreach (User u in chart.Users) usersString += u.Username + "<br />\r\n";
usersString.Remove(usersString.Length - 8);
index.Insert("user", usersString);
index.Insert("cancellationsInvolved", par.InvolveCancellation ? "ja" : "nein");
index.Insert("deletedArticlesShown", par.ShowDeletedArticles ? "ja" : "nein");
index.Insert("sortedBy", par.SortOrder.ToString());
#endregion
#region articles
HtmlTemplate articles = new HtmlTemplate("articlecollection");
articles.Insert("header", "Artikel");
foreach (ArticleCount ac in result.Sales.Container)
{
if (!par.ShowDeletedArticles && ac.Article.IsDeleted) continue;
if (!par.ShowUnsoldArticles && ac.Count < 1) continue;
HtmlTemplate tpl = new HtmlTemplate("article");
tpl.Insert("name", ac.Article.Name);
tpl.Insert("price", string.Format("{0:0.00 €}", ac.Article.Price));
tpl.Insert("count", par.InvolveCancellation ?
(ac.Count - result.Cancellations[ac.Article].Count).ToString() :
ac.Count.ToString());
tpl.Insert("sum", par.InvolveCancellation ?
string.Format("{0:0.00 €}", ac.Article.Price * (ac.Count - result.Cancellations[ac.Article].Count)) :
string.Format("{0:0.00 €}", ac.Article.Price * ac.Count));
articlesString += tpl.Get();
}
articles.Insert("articles", articlesString);
articles.Insert("articlescount", par.InvolveCancellation ?
(result.Sales.Count - result.Cancellations.Count).ToString() :
result.Sales.Count.ToString());
sum = par.InvolveCancellation ? (result.Sales.Amount - result.Cancellations.Amount) : result.Sales.Amount;
articles.Insert("articlessum", string.Format("{0:0.00 €}", sum));
index.Insert("sales", articles.Get());
#endregion
#region deposits
double depositSum = 0.0;
int depositCount = 0;
List<ArticleCount> deps = (from d in result.Sales.Container where d.Article.Deposit.DepositID != -1 select d as ArticleCount).ToList();
List<ArticleCount> depcancs = (from d in result.Cancellations.Container where d.Article.Deposit.DepositID != -1 select d as ArticleCount).ToList();
Cart depresult = new Cart();
foreach (ArticleCount d in deps)
depresult.Add(d);
if (par.InvolveCancellation) // remove cancelled deposites
foreach (ArticleCount d in depcancs)
depresult.Remove(d);
// add returned deposites which are not children of depresult (never bought it, but returned it)
List<DepositReturn> unbought = (from d in result.DepositReturns
where
(from a in depresult.Container select a.Article.Deposit).ToList<Deposit>().Contains(d.Deposit) == false
select d).ToList();
foreach (DepositReturn d in unbought)
{
int count = d.Count;
HtmlTemplate tpl = new HtmlTemplate("article");
tpl.Insert("name", d.Deposit.Name);
tpl.Insert("price", string.Format("{0:0.00 €}", d.Deposit.Amount));
tpl.Insert("count", count.ToString());
tpl.Insert("sum", string.Format("{0:0.00 €}", count * d.Deposit.Amount));
depositSum -= count * d.Deposit.Amount;
depositCount -= count;
depositsString += tpl.Get();
}
// enumerate deposit objects
foreach (ArticleCount d in depresult.Container)
{
int count = d.Count;
// subtract returned deposites
foreach (DepositReturn dr in (from ret in result.DepositReturns where ret.Deposit.DepositID == d.Article.Deposit.DepositID select ret).ToList())
{
count -= dr.Count;
}
HtmlTemplate tpl = new HtmlTemplate("article");
tpl.Insert("name", d.Article.Deposit.Name);
//.........這裏部分代碼省略.........