mirror of
https://github.com/rudollee/LearningMVC.git
synced 2026-08-11 16:32:55 +00:00
Primitive Commit
This commit is contained in:
@@ -0,0 +1,20 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Web;
|
||||
|
||||
namespace LanguageFeatures.Models
|
||||
{
|
||||
public static class MyExtensionMethods
|
||||
{
|
||||
public static decimal TotalPrices(this IEnumerable<Product> productEnum)
|
||||
{
|
||||
decimal total = 0;
|
||||
foreach (Product prod in productEnum)
|
||||
{
|
||||
total += prod.Price;
|
||||
}
|
||||
return total;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Web;
|
||||
|
||||
namespace LanguageFeatures.Models
|
||||
{
|
||||
public class Product
|
||||
{
|
||||
private string name;
|
||||
public int ProductID { get; set; }
|
||||
public string Name {
|
||||
get {
|
||||
return ProductID + name;
|
||||
}
|
||||
set {
|
||||
name = value;
|
||||
}
|
||||
}
|
||||
public string Description { get; set; }
|
||||
public decimal Price { get; set; }
|
||||
public string Category { get; set; }
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Web;
|
||||
|
||||
namespace LanguageFeatures.Models
|
||||
{
|
||||
public class ShoppingCart: IEnumerable<Product>
|
||||
{
|
||||
public List<Product> Products { get; set; }
|
||||
|
||||
public IEnumerator<Product> GetEnumerator()
|
||||
{
|
||||
return Products.GetEnumerator();
|
||||
}
|
||||
|
||||
IEnumerator IEnumerable.GetEnumerator()
|
||||
{
|
||||
return GetEnumerator();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user