当前位置: 首页>>代码示例>>C#>>正文


C# ProductViewModel类代码示例

本文整理汇总了C#中ProductViewModel的典型用法代码示例。如果您正苦于以下问题:C# ProductViewModel类的具体用法?C# ProductViewModel怎么用?C# ProductViewModel使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


ProductViewModel类属于命名空间,在下文中一共展示了ProductViewModel类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Create

    public IEnumerable<ProductViewModel> Create(ProductViewModel product)
    {
        using (var northwind = new Northwind())
        {
            // Create a new Product entity and set its properties from target
            var target = new Product
            {
                ProductName = product.ProductName,
                UnitPrice = product.UnitPrice,
                UnitsInStock = product.UnitsInStock,
                Discontinued = product.Discontinued
            };

            // Add the entity
            northwind.Products.AddObject(target);

            // Insert all created product to the database
            northwind.SaveChanges();

            product.ProductID = target.ProductID;

            // Return the inserted product - the Kendo Grid needs their ProductID which is generated by SQL server during insertion
            return new[] { product };
        }
    }
开发者ID:rodj,项目名称:kendo-examples-asp-net,代码行数:25,代码来源:Products.cs

示例2: Details

 public ActionResult Details(ProductViewModel productDetails)
 {
     IEnumerable<Product> lstProduct = null;
     if (!string.IsNullOrEmpty(productDetails.PID))
     {
         lstProduct = ProductService.FindBy(p => p.PID == productDetails.PID);
     }
     else
     {
         productDetails.ToDate = new DateTime(productDetails.ToDate.Year, productDetails.ToDate.Month, productDetails.ToDate.Day, 23, 59, 59);
         if (productDetails.ToDate.Year >= 1900 && productDetails.FromDate.Year >= 1900)
         {
             lstProduct = ProductService.FindBy(p => p.CreatedDate >= productDetails.FromDate && p.CreatedDate <= productDetails.ToDate);
         }
         else if (productDetails.ToDate.Year >= 1900 && productDetails.FromDate.Year <= 1900)
         {
             lstProduct = ProductService.FindBy(p => p.CreatedDate >= DateTime.MinValue && p.CreatedDate <= productDetails.ToDate);
         }
         else if (productDetails.ToDate.Year <= 1900 && productDetails.FromDate.Year >= 1900)
         {
             lstProduct = ProductService.FindBy(p => p.CreatedDate >= productDetails.FromDate && p.CreatedDate <= DateTime.MaxValue);
         }
         else
         {
             lstProduct = ProductService.FindBy(p => p.CreatedDate >= DateTime.MinValue && p.CreatedDate <= DateTime.MaxValue);
         }
     }
     productDetails.lstProducts = lstProduct;
     ViewBag.ResultMessage = lstProduct.Count() == 0 ? "No Record Found" : "";
     return View(productDetails);
 }
开发者ID:amit11987,项目名称:LatestSourceCode,代码行数:31,代码来源:ProductController.cs

示例3: Map

 public Product Map(ProductViewModel model)
 {
     return new Product
     {
         Name = model.Name,
     };
 }
开发者ID:nyetsi,项目名称:ShoppingCart,代码行数:7,代码来源:ShoppingCartController.cs

示例4: Create

        public Action Create(ProductViewModel productViewModel)
        {
            var product = _mapper.Map(productViewModel);
            ShoppingCart cart = _shoppingCartService.AddShoppingCart(product);

            return null;
        }
开发者ID:nyetsi,项目名称:ShoppingCart,代码行数:7,代码来源:ShoppingCartController.cs

示例5: GetProductInformation

        /// <summary>
        /// Get Product Information
        /// </summary>
        /// <param name="viewModel"></param>
        /// <returns></returns>
        ///
        /// <summary>
        /// Product Inquiry
        /// </summary>
        /// <param name="viewModel"></param>
        /// <returns></returns>
        public ProductViewModel GetProductInformation(int productID)
        {
            Product product = new Product();
            ProductViewModel productViewModel = new ProductViewModel();

            if (productID == 0)
            {
                List<String> returnMessage = new List<String>();
                returnMessage.Add("An invalid product ID was entered.");
                productViewModel.ReturnMessage = returnMessage;
                productViewModel.ReturnStatus = false;
                return productViewModel;
            }

            ProductDataAccessService productDataAccessService = new ProductDataAccessService();

            product = productDataAccessService.GetProductInformation(productID);
            productViewModel.Product = product;
            productViewModel.ReturnStatus = true;

            if (product.ProductID == 0)
            {
                List<String> returnMessage = new List<String>();
                returnMessage.Add(productID.ToString() + " is not a valid product ID");
                productViewModel.ReturnMessage = returnMessage;
                productViewModel.ReturnStatus = false;
            }

            return productViewModel;
        }
开发者ID:githileco,项目名称:ethiohilecomvctoysapp2017,代码行数:41,代码来源:ProductApplicationService.cs

示例6: Index

        //
        // GET: /Shop/
        public ActionResult Index()
        {
            if (Session["Cart"] == null) // haven't been to db yet
            {
                try
                {
                    ProductViewModel prod = new ProductViewModel();
                    List<ProductViewModel> Prods = prod.GetAll();
                    if (Prods.Count() > 0)
                    {
                        CartItem[] myCart = new CartItem[Prods.Count]; // array
                        int ctr = 0;

                        // build CartItem array from List contents
                        foreach (ProductViewModel p in Prods)
                        {
                            CartItem item = new CartItem();
                            item.ProdCd = p.ProdCode;
                            item.ProdName = p.ProdName;
                            item.Graphic = p.Graphic;
                            item.Msrp = p.Msrp;
                            item.Description = p.Description;
                            item.Qty = 0;
                            myCart[ctr++] = item;
                        }
                        Session["Cart"] = myCart;  // load to session
                    }
                }
                catch (Exception ex)
                {
                    ViewBag.Message = "Catalogue Problem - " + ex.Message;
                }
            }
            return View();
        }
开发者ID:elauersen,项目名称:Info3067Case1,代码行数:37,代码来源:ShopController.cs

示例7: Index

        public ActionResult Index()
        {
            var productViewModel = new ProductViewModel();
            productViewModel.Products = _productService.GetAllProducts().ToList();

            return View(productViewModel);
        }
开发者ID:rcapil,项目名称:NorthwindDemo,代码行数:7,代码来源:HomeController.cs

示例8: ProductList

        public async Task<ActionResult> ProductList()
        {
            try
            {
                ParseQuery<ParseObject> query = ParseObject.GetQuery("Product");
                IEnumerable<ParseObject> productList = await query.FindAsync();

                List<ProductViewModel> _productList = new List<ProductViewModel>();

                foreach (ParseObject p in productList)
                {

                    ProductViewModel model = new ProductViewModel(p);
                    ParseQuery<ParseObject> q = ParseObject.GetQuery("Specification");
                    ParseObject specification = await q.GetAsync(model.specification.specificationId);
                    
                }

                return View();
            }
            catch (ParseException pe)
            {
                return View();
            }
        }
开发者ID:kduytoan1994,项目名称:Mobile,代码行数:25,代码来源:ProductController.cs

示例9: DefaultBrickData

        public ProductViewModel DefaultBrickData()
        {
            ProductViewModel productViewModel = new ProductViewModel();
            productViewModel.Products = new List<ProductEntity>();

            for (int i = 1; i < 8; i++)
            {
                var product = new ProductEntity();
                product.Id = i;
                if(i%2 == 0)
                {
                    product.Name = "Antique Stratford";
                    product.Description = "A look of modern elegance; Antique Stratford has a deep maroon body with a soft splash of white accent.";
                    product.SampleImagePath = "brickSample.png";
                    product.Images = new List<string>
                                         {"AntiqueStratford_1.jpg", "AntiqueStratford_2.jpg", "AntiqueStratford_3.jpg"};
                }
                else
                {
                    product.Name = "Cambridge";
                    product.Description = "Cambridge is a traditional deep red brick boasting a uniform color with a classic marbled texture.";
                    product.SampleImagePath = "brickSample.png";
                    product.Images = new List<string> { "Cambridge_1.jpg", "Cambridge_2.jpg", "Cambridge_3.jpg" };
                }

                productViewModel.Products.Add(product);

            }

            return productViewModel;
        }
开发者ID:dajukie7,项目名称:TrinityBrick,代码行数:31,代码来源:ProductController.cs

示例10: Add

 /// <summary>
 /// Добавление курса в репозиторий
 /// </summary>
 /// <param name="product"></param>
 public void Add(ProductViewModel product)
 {
     product.CreatedDate = product.UpdatedDate = DateTime.Now;
     if (product.AssignedUserId == 0)
         product.AssignedUserId = null;
     productRepository.Add(ConvertFromProductViewModelToProduct(product));
 }
开发者ID:denismaster,项目名称:dotnet01,代码行数:11,代码来源:ProductService.cs

示例11: Details

        public ActionResult Details(string code)
        {
            RestClient<Product> productsRestClient = new RestClient<Product>("http://localhost:3001/");
            var product = productsRestClient.Get("products/code/" + code).Result;

            // TODO: Fix this in EF
            product.Supplier = new Supplier
            {
                Id = product.SupplierId,
                Name = "My Supplier"
            };

            var productViewModel = new ProductViewModel()
            {
                Id = product.Id,
                Code = product.Code,
                Name = product.DisplayName,
                Price = product.UnitPrice,
                SupplierName = product.Supplier.Name
            };

            ProductViewModel another = Mapper.Map<ProductViewModel>(product);

            return View(another);
        }
开发者ID:alertbox,项目名称:stocksly,代码行数:25,代码来源:ProductsController.cs

示例12: Products_Update

 public ActionResult Products_Update([DataSourceRequest]DataSourceRequest request, ProductViewModel product)
 {
     if (ModelState.IsValid)
     {
         using (var northwind = new NorthwindEntities())
         {
             // Create a new Product entity and set its properties from the posted ProductViewModel
             var entity = new Product
             {
                 ProductID = product.ProductID,
                 ProductName = product.ProductName,
                 UnitsInStock = product.UnitsInStock
             };
             // Attach the entity
             northwind.Products.Attach(entity);
             // Change its state to Modified so Entity Framework can update the existing product instead of creating a new one
             northwind.Entry(entity).State = EntityState.Modified;
             // Or use ObjectStateManager if using a previous version of Entity Framework
             // northwind.ObjectStateManager.ChangeObjectState(entity, EntityState.Modified);
             // Update the entity in the database
             northwind.SaveChanges();
         }
     }
     // Return the updated product. Also return any validation errors.
     return Json(new[] { product }.ToDataSourceResult(request, ModelState));
 }
开发者ID:turtlechalk,项目名称:ui-for-aspnet-mvc-examples,代码行数:26,代码来源:HomeController.cs

示例13: ProductListToProductViewModelList

        public static List<ProductViewModel> ProductListToProductViewModelList(List<Product> products, int userId, Vote vote)
        {
            List<ProductViewModel> prods = new List<ProductViewModel>();

            int votedProductId = 0;
            if (vote != null)
            {
               votedProductId  = vote.ProductId;
            }

            foreach (var item in products)
            {
                ProductViewModel prod = new ProductViewModel();
                prod.Id = item.Id;
                prod.Name = item.Name;
                prod.Description = item.Description;
                prod.ImagePath = item.ImagePath;
                prod.VotesAmount = (item.Votes != null) ? item.Votes.Count() : 0;
                prod.ButtonClass = (item.Id == votedProductId) ? EnumDescription.GetEnumDescription(ButtonClass.Voted) : EnumDescription.GetEnumDescription(ButtonClass.Default);
                prod.EditActionLink = "/Home/Edit/" + item.Id;
                prods.Add(prod);
            }

            return prods;
        }
开发者ID:uczenn,项目名称:VoteProject,代码行数:25,代码来源:Bindings.cs

示例14: Details

        public async Task<ActionResult> Details(int? id)
        {
            if (id == null)
            {
                return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
            }
            var product  = await _db.Products.Where(p => p.ProductId == id).Include(p => p.SoftwarePolicy).Include(p => p.ProductCategory).Include(p => p.ProductType).Include(p => p.LocalAccountVerification).Include(p => p.ProductsPermissions).FirstOrDefaultAsync();
            if (product == null)
            {
                return HttpNotFound("Unable to retrieve the selected product");
            }
            var productViewModel = new ProductViewModel(product);

            if (ContainsInvalid(productViewModel.Version))
            {
                ViewBag.DetailTitle = productViewModel.Name;
            }
            else if (productViewModel.Name.Contains(productViewModel.Version))
            {
                ViewBag.DetailTitle = productViewModel.Name;
            }
            else
            {
                ViewBag.DetailTitle = $"{productViewModel.Name} {productViewModel.Version}";
            }
            return View(productViewModel);
        }
开发者ID:akiker,项目名称:CV2,代码行数:27,代码来源:SoftwareController.cs

示例15: About

        public ActionResult About( int? id)
        {
            if (User.Identity.GetUserId() != null)
            {
                var productRepository = new ProductRepository();
                var pvm = new ProductViewModel();

                var gpab = productRepository.GetPeopleAlsoBought(id);

                pvm.PeopleAlsoBought = gpab;
                var idprod = productRepository.GetProductDetails(id);

                pvm.LargePhoto = idprod.LargePhoto;
                pvm.listPrice = idprod.listPrice;
                pvm.Name = idprod.Name;
                pvm.ProductId = idprod.ProductId;
                pvm.color = idprod.color;
                pvm.Weight = idprod.Weight;
                pvm.size = idprod.size;
                pvm.description = idprod.description;
                ViewBag.Message = "Your application description page.";

                return View(pvm);
            }
            else
            {
                return RedirectToAction("Login", "Account");
            }
        }
开发者ID:djonnala,项目名称:NetApp,代码行数:29,代码来源:HomeController.cs


注:本文中的ProductViewModel类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。