本文整理汇总了C#中Models.Product类的典型用法代码示例。如果您正苦于以下问题:C# Product类的具体用法?C# Product怎么用?C# Product使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Product类属于Models命名空间,在下文中一共展示了Product类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: BeginPutNonRetry400Async
/// <summary>
/// Long running put request, service returns a 400 to the initial request
/// </summary>
/// <param name='operations'>
/// The operations group for this extension method.
/// </param>
/// <param name='product'>
/// Product to put
/// </param>
/// <param name='cancellationToken'>
/// The cancellation token.
/// </param>
public static async Task<Product> BeginPutNonRetry400Async(this ILROSADsOperations operations, Product product = default(Product), CancellationToken cancellationToken = default(CancellationToken))
{
using (var _result = await operations.BeginPutNonRetry400WithHttpMessagesAsync(product, null, cancellationToken).ConfigureAwait(false))
{
return _result.Body;
}
}
示例2: DeepCopyProduct
/// <summary>
/// Makes deep copy of Product.
/// Entity Framework cannot keep track of 1 item in 2 contexts, so in order to
/// export something and import it in other database it needs deep copy of it.
/// </summary>
/// <param name="product">Product for copy.</param>
/// <param name="vendor">Product's vendor.</param>
/// <returns>Deep copy of the product</returns>
private static Product DeepCopyProduct(Product product, Vendor vendor)
{
var incomes = product.Incomes
.Select(income => new Income()
{
Quantity = income.Quantity,
SalePrice = income.SalePrice
})
.ToList();
var expenses = product.Vendor.Expenses
.Select(expense => new Expense()
{
Amount = expense.Amount,
})
.ToList();
foreach (var expense in expenses)
{
vendor.Expenses.Add(expense);
}
var deepCopyProduct = new Product()
{
Name = product.Name,
BuyingPrice = product.BuyingPrice,
Incomes = incomes,
Vendor = vendor
};
return deepCopyProduct;
}
示例3: Put200SucceededAsync
/// <summary>
/// Long running put request, service returns a 200 to the initial request,
/// with an entity that contains ProvisioningState=’Succeeded’.
/// </summary>
/// <param name='operations'>
/// The operations group for this extension method.
/// </param>
/// <param name='product'>
/// Product to put
/// </param>
/// <param name='cancellationToken'>
/// The cancellation token.
/// </param>
public static async Task<Product> Put200SucceededAsync(this ILROsOperations operations, Product product = default(Product), CancellationToken cancellationToken = default(CancellationToken))
{
using (var _result = await operations.Put200SucceededWithHttpMessagesAsync(product, null, cancellationToken).ConfigureAwait(false))
{
return _result.Body;
}
}
示例4: GetProductAsync
/// <summary>
/// Product Types
/// </summary>
/// <param name='operations'>
/// The operations group for this extension method.
/// </param>
/// <param name='responseCode'>
/// The desired returned status code
/// </param>
/// <param name='product'>
/// The only parameter
/// </param>
/// <param name='cancellationToken'>
/// The cancellation token.
/// </param>
public static async Task<Product> GetProductAsync(this ISwaggerDataTypesClient operations, string responseCode = default(string), Product product = default(Product), CancellationToken cancellationToken = default(CancellationToken))
{
using (var _result = await operations.GetProductWithHttpMessagesAsync(responseCode, product, null, cancellationToken).ConfigureAwait(false))
{
return _result.Body;
}
}
示例5: PostAsync
/// <summary>
/// Products
/// </summary>
/// The Products endpoint returns information about the Uber products offered
/// at a given location. The response includes the display name and other
/// details about each product, and lists the products in the proper display
/// order.
/// <param name='operations'>
/// The operations group for this extension method.
/// </param>
/// <param name='subscriptionId'>
/// Subscription Id.
/// </param>
/// <param name='resourceGroupName'>
/// Resource Group Id.
/// </param>
/// <param name='apiVersion'>
/// API Id.
/// </param>
/// <param name='body'>
/// API body mody.
/// </param>
/// <param name='cancellationToken'>
/// The cancellation token.
/// </param>
public static async Task<Product> PostAsync( this IRecursiveTypesAPI operations, string subscriptionId, string resourceGroupName, string apiVersion, Product body = default(Product), CancellationToken cancellationToken = default(CancellationToken))
{
using (var _result = await operations.PostWithHttpMessagesAsync(subscriptionId, resourceGroupName, apiVersion, body, null, cancellationToken).ConfigureAwait(false))
{
return _result.Body;
}
}
示例6: Put201CreatingSucceeded200Async
/// <summary>
/// Long running put request, service returns a 500, then a 201 to the initial
/// request, with an entity that contains ProvisioningState=’Creating’.
/// Polls return this value until the last poll returns a ‘200’ with
/// ProvisioningState=’Succeeded’
/// </summary>
/// <param name='operations'>
/// The operations group for this extension method.
/// </param>
/// <param name='product'>
/// Product to put
/// </param>
/// <param name='cancellationToken'>
/// The cancellation token.
/// </param>
public static async System.Threading.Tasks.Task<Product> Put201CreatingSucceeded200Async(this ILRORetrysOperations operations, Product product = default(Product), System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken))
{
using (var _result = await operations.Put201CreatingSucceeded200WithHttpMessagesAsync(product, null, cancellationToken).ConfigureAwait(false))
{
return _result.Body;
}
}
示例7: Delete
public void Delete(Product product)
{
var products = db.GetCollection<Product>("Products");
var query = Query.And(Query.EQ("Price", product.Price), Query.EQ("Name", product.Name));
var findAndRemoveArguments = new FindAndRemoveArgs();
findAndRemoveArguments.Query = query;
products.FindAndRemove(findAndRemoveArguments);
}
示例8: insert_Click
private void insert_Click(object sender, EventArgs e)
{
Product product = new Product
{
Id = Int32.Parse(insertId.Text),
Name = insertName.Text,
Price = Double.Parse(insertPrice.Text),
Quantity = Int32.Parse(insertQuantity.Text)
};
DbAccessor accessor = DbAccessor.Instance;
accessor.CreateProduct(product);
}
示例9: Edit
public ActionResult Edit(Product model, int id)
{
if (ModelState.IsValid)
{
_models.Remove(_models.Get(id));
model.Id = id;
_models.Add(model);
Success("The model was updated!");
return RedirectToAction("index");
}
return View("Create", model);
}
示例10: Create
public ActionResult Create(Product model)
{
if (ModelState.IsValid)
{
model.Id = _models.Count == 0 ? 1 : _models.Select(x => x.Id).Max() + 1;
_models.Add(model);
Success("Your information was saved!");
return RedirectToAction("Index");
}
Error("there were some errors in your form.");
return View(model);
}
示例11: Insert
public ActionResult Insert()
{
using (var db = new NorthwindDataContext())
{
var product = new Product();
if (TryUpdateModel(product))
{
db.Products.InsertOnSubmit(product);
db.SubmitChanges();
}
}
return GetView();
}
示例12: Create
public ActionResult Create(Product product)
{
try
{
productRepository.Add(product);
productRepository.Save();
return RedirectToAction("Index");
}
catch
{
return View();
}
}
示例13: InsertProduct
public string InsertProduct(Product product)
{
try
{
GarageEntities db = new GarageEntities();
db.Products.Add(product);
db.SaveChanges();
return product.Name + " was succesfully inserted";
}
catch (Exception e)
{
return "Error:" + e;
}
}
示例14: Create
public ActionResult Create(Product product,HttpPostedFileBase file,FormCollection values)
{
if (ModelState.IsValid)
{
if (file != null)
{
product.ProductStores = new List<ProductStore>();
product.ProductStores.Add(new ProductStore { SellPrice = Convert.ToDecimal(values["SellPrice"]), TimeCreated = DateTime.Now, });
product.Image = new byte[file.ContentLength];
file.InputStream.Read(product.Image, 0, file.ContentLength);
storeDB.Products.Add(product);
storeDB.SaveChanges();
}
return RedirectToAction("");
}
ViewBag.CategorieID = new SelectList(storeDB.Caegories, "CategorieID", "Name");
return View();
}
示例15: ListAll
public List<Product> ListAll()
{
_products = new List<Product>();
string[] reader = File.ReadAllLines(FilePath);
for (int i = 1; i < reader.Length; i++)
{
var columns = reader[i].Split(',');
var product = new Product
{
ProductType = columns[0],
CostPerSquareFoot= decimal.Parse(columns[1]),
LaborCostPerSquareFoot = decimal.Parse(columns[2]),
};
_products.Add(product);
}
return _products;
}