本文整理汇总了C#中ProductModel类的典型用法代码示例。如果您正苦于以下问题:C# ProductModel类的具体用法?C# ProductModel怎么用?C# ProductModel使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ProductModel类属于命名空间,在下文中一共展示了ProductModel类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: Create
public ActionResult Create(ProductModel model)
{
bool isNotExist = _productRepo.FindDuplicateByName(model.Name);
if (isNotExist)
{
Categories category = _categoryRepo.Get(Int32.Parse(model.Category));
Manufacturers manufacturer = _manufacturersRepo.Get(Int32.Parse(model.Manufacturer));
var product = new Products(model.Name, model.Description,
Convert.ToDecimal(model.Price, CultureInfo.InvariantCulture), category, manufacturer,
Int32.Parse(model.Quantity), model.IsFeatured, model.IsRecent, model.IsBestSeller, model.ShortDescription);
try
{
_productRepo.Save(product);
TempData["success"] = "Pomyślnie dodano nowy towar.";
return RedirectToAction("index");
}
catch (Exception)
{
TempData["error"] = "Wystąpił problem z połączeniem do bazy danych.";
return RedirectToAction("Create");
}
}
TempData["error"] = "Towar o podanej nazwie już istnieje";
return RedirectToAction("Create");
}
开发者ID:gpierzchala,项目名称:InternetStore,代码行数:27,代码来源:ProductsController.cs
示例2: Get
public GridResponseModel<ProductModel> Get(GridRequestModel gridRequestModel, ProductModel searchModel)
{
var query = _unitOfWork.ProductRepository.Queryable;
if (searchModel != null)
{
if (searchModel.ProductTypeId > 0)
query = query.Where(p => p.ProductType.Id == searchModel.ProductTypeId);
if (searchModel.SupplierId > 0)
query = query.Where(p => p.Supplier != null && p.Supplier.Id == searchModel.SupplierId);
if (!string.IsNullOrWhiteSpace(searchModel.Name))
query = query.Where(p => p.Name.Contains(searchModel.Name));
}
switch (gridRequestModel.Sidx)
{
default:
case "Name":
query = query.OrderBy(p => p.Name, gridRequestModel.IsSortAsending);
break;
}
var dbModel = query.ToPagingResult(gridRequestModel);
var model = dbModel.Rows.Select(m => Mapper.Map<ProductModel>(m)).ToArray();
var gridData = new GridResponseModel<ProductModel>(gridRequestModel, dbModel.RowCount, model);
return gridData;
}
开发者ID:HuaHom,项目名称:WebApplication1,代码行数:29,代码来源:ProductService.cs
示例3: MainViewResult
public ViewResult MainViewResult()
{
var viewResult = new ViewResult();
viewResult.ViewName = "Index";
var userProducts = new ProductModel(Domain.User.Products);
userProducts.Refresh();
var userAccount = new AccountModel(Domain.User.Account);
userAccount.Refresh();
var vmProducts = new ProductModel(Domain.VM.Products);
vmProducts.Refresh();
var vmBankAccount = new AccountModel(Domain.VM.BankAccount);
vmBankAccount.Refresh();
viewResult.ViewBag.UserProducts = userProducts;
viewResult.ViewBag.UserAccount = userAccount;
viewResult.ViewBag.VMProducts = vmProducts;
viewResult.ViewBag.VMBankAccount = vmBankAccount;
viewResult.ViewBag.VMUserAccount = Domain.VM.UserAccount;
return viewResult;
}
开发者ID:petuhovam,项目名称:home,代码行数:25,代码来源:HomeController.cs
示例4: FillPage
private void FillPage()
{
//Get selected product's data
if (!String.IsNullOrWhiteSpace(Request.QueryString["id"]))
{
int id = Convert.ToInt32(Request.QueryString["id"]);
ProductModel productModel = new ProductModel();
Product product = productModel.GetProduct(id);
ZHUW15sqlserver1Entities db = new ZHUW15sqlserver1Entities();
//Fill Page with data
lblColor.Text = " " + product.Color;
lblPrice.Text = " $" + product.Price;
lblTitle.Text = product.Name;
lblDescription.Text = product.Description;
lblProductNum.Text = "Product Number: "+ id.ToString();
imgProdcut.ImageUrl = "~/Image/Products/" + product.Image;
//Retrieve supplier
int supplierId = product.SupplierID;
Supplier supplier = db.Suppliers.Find(supplierId);
lblSupplier.Text = "By " + supplier.Name;
//Fille amount dropdown list with numbers 1-30;
int[] quantity = Enumerable.Range(1, 30).ToArray();
ddlQuantity.DataSource = quantity;
ddlQuantity.AppendDataBoundItems = true;
ddlQuantity.DataBind();
}
}
开发者ID:alicezhuwy,项目名称:Asp.net-webshop,代码行数:31,代码来源:SingleProduct.aspx.cs
示例5: VmShouldUseResourceNameEditEntity
public void VmShouldUseResourceNameEditEntity()
{
var model = new ProductModel();
var viewModel = GetViewModel<ProductEditorViewModel>();
viewModel.InitializeEntity(model, false);
Assert.AreEqual(viewModel.DisplayName, UiResources.ProductEditDisplayName);
}
开发者ID:Fezzer,项目名称:MugenMvvmToolkit.Samples,代码行数:7,代码来源:ProductEditorViewModelTest.cs
示例6: ManyToManyUpdateTest
public void ManyToManyUpdateTest()
{
using (EasySession easySession = new EasySession())
{
///[Test Update] - many-to-many relationship
ProductModelIllustration productModelIllustration = new ProductModelIllustration();
int resultCount = productModelIllustration.Count(easySession);
Assert.AreEqual(5, resultCount);
ProductModel productModel = new ProductModel();
resultCount = productModel.Count(easySession);
Assert.AreEqual(129, resultCount);
productModel.ProductModelID = 47;
ProductModel resultList = productModel.Find(easySession, EasyLoad.Simple);
//resultList.Illustration.RemoveAt(0);
bool result = resultList.Update(easySession);
resultCount = resultList.Count(easySession);
Assert.AreEqual(129, resultCount);
resultCount = productModelIllustration.Count(easySession);
Assert.AreEqual(5, resultCount);
}
}
开发者ID:hasi,项目名称:EasyData,代码行数:26,代码来源:Update.aspx.cs
示例7: GetProduct
//GET api/products/{productId}
public HttpResponseMessage GetProduct(int productId, [ValueProvider(typeof(HeaderValueProviderFactory<string>))]string sessionKey)
{
var responseMsg = this.PerformOperationAndHandleExceptions<HttpResponseMessage>(
() =>
{
using (var context = new StoreContext())
{
this.ValidateSessionKey(sessionKey);
var product = context.Products.Include("Category").FirstOrDefault(p => p.Id == productId);
if (product == null)
{
throw new ArgumentException("Product not found");
}
var resultProductModel = new ProductModel
{
Id = product.Id,
Name = product.Name,
Price = product.Price,
CategoryName = product.Category.Name,
CategoryId = product.Category.Id,
Description = product.Description,
ImageSource = product.ImageSource,
Quantity = product.Quantity
};
var response = this.Request.CreateResponse(HttpStatusCode.OK,
resultProductModel);
return response;
}
});
return responseMsg;
}
开发者ID:VelizarIT,项目名称:JSFrameworks-TantalumStore,代码行数:36,代码来源:ProductsController.cs
示例8: getProduct
public List<ProductModel> getProduct(IEnumerable<Product> data)
{
var list = new List<ProductModel>();
if (data != null)
{
foreach (var model in data)
{
var prod = new ProductModel();
if (model != null)
{
prod.CategoryId = model.CategoryId;
prod.Discontinued = model.Discontinued;
prod.Name = model.Name;
prod.ProductCategory = getCategory(model.ProductCategory);
prod.ProductId = model.ProductId;
prod.ProductSupplier = getSupplier(model.ProductSupplier);
prod.QuantityPerUnit = model.QuantityPerUnit;
prod.ReorderLevel = model.ReorderLevel;
prod.SupplierId = model.SupplierId;
prod.UnitPrice = model.UnitPrice;
prod.UnitsInStock = model.UnitsInStock;
prod.UnitsOnOrder = model.UnitsOnOrder;
}
list.Add(prod);
}
}
return list;
}
开发者ID:smubarak-ali,项目名称:store-angular,代码行数:29,代码来源:EntityToModelHelper.cs
示例9: Create
public void Create(ProductModel model)
{
var dbModel = Mapper.Map<Product>(model);
dbModel.ProductType = _unitOfWork.ProductTypeRepository.Get(model.ProductTypeId);
dbModel.Supplier = _unitOfWork.SupplierRepository.Get(model.SupplierId);
_unitOfWork.ProductRepository.Create(dbModel);
}
开发者ID:HuaHom,项目名称:WebApplication1,代码行数:8,代码来源:ProductService.cs
示例10: SaveProduct
public ActionResult SaveProduct(ProductModel model)
{
if(model != null)
{
model.SupplierId = 1;
_service.SaveProduct(model);
}
return new HttpStatusCodeResult(201, "Created Successfully");
}
开发者ID:smubarak-ali,项目名称:store-angular,代码行数:9,代码来源:ProductController.cs
示例11: Index
public ActionResult Index(string id)
{
var products = _unitOfWork.ProductRepository.Get().ToList();
var product = _unitOfWork.ProductRepository.GetById(new Guid(id));
if (product == null)
{
return View("Error");
}
var image800x640Paths = product.Image800x640Paths.ToList();
var imageAdditional = GetImageAdditionalModels(image800x640Paths);
var relatedProductIds = _unitOfWork.RelatedProductRepository.Get(i=>i.ProductId==new Guid(id)).Select(r=>r.RelatedProductId);
var relatedProducts = _unitOfWork.ProductRepository.Get(p => relatedProductIds.Contains(p.Id)).ToList();
var relatedProductBlocks = GetRelatedProductBlocks(relatedProducts);
var categoryViewModels = GetCategories(product, products);
var specialProduct = products.First(i => i.Id == new Guid("CD4879A0-C210-4DAA-A6DE-A59E9CC153BF"));
var specialProductViewModel = new SpecialProductViewModel
{
Id = specialProduct.Id.ToString(),
Name = specialProduct.Name,
OldPrice = specialProduct.OldPrice.HasValue ? specialProduct.OldPrice.Value.ToString("C") : string.Empty,
NewPrice = specialProduct.NewPrice.ToString("C"),
RatingImagePath = specialProduct.RatingImagePath,
Image240x192Path = specialProduct.Image240x192Path
};
var productInfo = new ProductInfo
{
Id = product.Id.ToString(),
Name = product.Name,
DefaultImage = image800x640Paths.First(i => i.IsActive).Path,
OldPrice = product.OldPrice.HasValue ? product.OldPrice.Value.ToString("C") : string.Empty,
NewPrice = product.NewPrice.ToString("C"),
ExTax = (product.NewPrice - product.NewPrice*.15m).ToString("C"),
Brand = product.Brand.Name,
BrandId = product.Brand.Id.ToString(),
Description = product.Description,
ImageAdditionals = imageAdditional,
Availability = "In Stock"
};
var productModel = new ProductModel
{
ProductInfo=productInfo,
RelatedProductBlocks = relatedProductBlocks,
RelatedProductCount=relatedProducts.Count,
CategoryViewModels=categoryViewModels,
SpecialProductViewModel=specialProductViewModel
};
return View(productModel);
}
开发者ID:HaoTan,项目名称:APlusSecurityNZ,代码行数:56,代码来源:ProductController.cs
示例12: Create
public ActionResult Create(ProductModel model)
{
if (this.ModelState.IsValid)
{
_productService.Create(model);
return RedirectToAction("Index");
}
return View(model);
}
开发者ID:HuaHom,项目名称:WebApplication1,代码行数:10,代码来源:ProductController.cs
示例13: CreateOrUpdate
public ActionResult CreateOrUpdate(ProductModel productModel)
{
if (ModelState.IsValid && productModel.IsValid())
{
this.productModelTasks.CreateOrUpdate(productModel);
return this.RedirectToAction(x => x.Index());
}
return View(productModel);
}
开发者ID:elbandit,项目名称:Sharp-Architecture-Cookbook,代码行数:10,代码来源:ProductModelsController.cs
示例14: FillPage
//FillPage() method
private void FillPage(int id)
{
ProductModel pModel = new ProductModel();
Product product = pModel.GetProduct(id);
descriptionTextBox.Text = product.Description;
nameTextBox.Text = product.Name;
priceTextBox.Text = product.Price.ToString();
imageDropDownList.SelectedValue = product.Image;
typeDropDownList.SelectedValue = product.Type.ToString();
quantityTextBox.Text = product.Quantity.ToString();
}
开发者ID:lester88a,项目名称:COMP229-Final-Example,代码行数:12,代码来源:ManageProduct.aspx.cs
示例15: AddBook
public ActionResult AddBook(HttpPostedFileBase file, AddProductViewModel model)
{
Session["Username"] = "Admin";
var userName = Session["Username"];
var imagePath = CreateMD5(model.Title + DateTime.Now + DateTime.Now.Millisecond + model.Detail) ;
var addViewModel = new ProductModel();
addViewModel.Title = model.Title;
addViewModel.Author = model.Author;
addViewModel.Image = imagePath;
addViewModel.Detail = model.Detail;
addViewModel.Balance = model.Balance;
addViewModel.Isbn = model.Isbn;
addViewModel.Price = model.Price;
addViewModel.CategoryId = model.CategoryId;
addViewModel.CreateBy = userName.ToString();
addViewModel.CreateTime = DateTime.Now;
addViewModel.UpdateBy = "Test Admin";
addViewModel.UpdateTime = DateTime.Now;
addViewModel.IsActive = true;
bool uploadImageIsComplete = true;
if (file != null && file.ContentLength > 0)
try
{
var fileName = imagePath + ".jpg";
var path = Path.Combine(Server.MapPath("~/Content/images/Product/"), fileName);
file.SaveAs(path);
}
catch (Exception ex)
{
uploadImageIsComplete = false;
}
else
{
uploadImageIsComplete = false;
}
if (uploadImageIsComplete)
{
ProductService productService = new ProductService();
if (productService.Save(addViewModel))
{
// return RedirectToRoute("~Success");
}
else
{
// return RedirectToRoute("~Error");
}
}
return RedirectToAction("ManageProductView", "ManageProduct");
}
开发者ID:yoak1234,项目名称:BookShopWorkShop,代码行数:53,代码来源:ManageProductController.cs
示例16: Put
// PUT api/awbuildversion/5
public void Put(ProductModel value)
{
var GetActionType = Request.Headers.Where(x => x.Key.Equals("ActionType")).FirstOrDefault();
if (GetActionType.Key != null)
{
if (GetActionType.Value.ToList()[0].Equals("DELETE"))
adventureWorks_BC.ProductModelDelete(value);
if (GetActionType.Value.ToList()[0].Equals("UPDATE"))
adventureWorks_BC.ProductModelUpdate(value);
}
}
开发者ID:oigbokwe73,项目名称:AdventureWorks,代码行数:13,代码来源:ProductModelController.cs
示例17: FillPage
private void FillPage(int id ){
ProductModel productModel = new ProductModel();
Product product = productModel.GetProduct(id);
txtDescription.Text = product.Description;
txtName.Text = product.Name;
txtPrice.Text = product.Price.ToString();
ddlImage.SelectedValue = product.Image;
ddlType.SelectedValue = product.TypeId.ToString();
}
开发者ID:Rita124,项目名称:Rita124.github.io,代码行数:13,代码来源:ManageProducts.aspx.cs
示例18: SPTest
protected void SPTest()
{
using (EasySession easySession = new EasySession())
{
ProductModel productModel = new ProductModel();
int resultCount = productModel.Count(easySession);
Assert.AreEqual(129, resultCount);
ObjectQuery testOQ = new ObjectQuery();
//testOQ.DeleteSP("uspDeleteProductModels", easySession).SetParameterList("list", new int[] { 1, 2, 3 }, typeof(int)).Execute();
resultCount = productModel.Count(easySession);
Assert.AreEqual(126, resultCount);
}
}
开发者ID:hasi,项目名称:EasyData,代码行数:15,代码来源:Query.aspx.cs
示例19: btnSubmit_Click
protected void btnSubmit_Click(object sender, EventArgs e)
{
ProductModel productModel = new ProductModel();
Product product = CreateProduct();
if (!String.IsNullOrWhiteSpace(Request.QueryString["id"]))
{
int id = Convert.ToInt32(Request.QueryString["id"]);
lblResult.Text = productModel.UpdateProduct(id, product);
}
else
{
lblResult.Text = productModel.InsertProduct(product);
}
}
开发者ID:SaifAsad,项目名称:garager,代码行数:15,代码来源:ManageProducts.aspx.cs
示例20: QueryTest
protected void QueryTest()
{
using (EasySession easySession = new EasySession())
{
ProductModel productModel = new ProductModel();
int resultCount = productModel.Count(easySession);
Assert.AreEqual(129, resultCount);
ObjectQuery testOQ = new ObjectQuery();
//testOQ.EasyQuery(easySession).From(productModel.GetType()).Where().
//var result = testOQ.DeleteQuery("DELETE FROM Production.ProductModel WHERE ProductModelID IN (:list)", easySession).SetParameterList("list", new int[] { 1, 2, 3 }, typeof(int)).Execute();
resultCount = productModel.Count(easySession);
Assert.AreEqual(126, resultCount);
}
}
开发者ID:hasi,项目名称:EasyData,代码行数:16,代码来源:Query.aspx.cs
注:本文中的ProductModel类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论