示例#1
0
        public void Delete(int Id, Product prod)
        {
            Product product = (from cust in _dataContext.Products
                               where cust.Id == Id
                               select cust).FirstOrDefault();

            _dataContext.DeleteObject(product);
            _dataContext.SaveChanges();
        }
示例#2
0
        public void Edit(int id, Product product)
        {
            Product paintingToEdit = (from cust in _dataContext.Products
                                      where cust.Id == id
                                      select cust).FirstOrDefault();

            paintingToEdit.Image = product.Image;
            paintingToEdit.Name = product.Name;
            paintingToEdit.MimeType = product.MimeType;
            paintingToEdit.Description = product.Description;
            paintingToEdit.Length = product.Length;
            paintingToEdit.Width = product.Width;
            paintingToEdit.Material = product.Material;
            paintingToEdit.ModifiedDate = DateTime.Now;

            _dataContext.SaveChanges();
        }
示例#3
0
 /// <summary>
 /// Deprecated Method for adding a new object to the Products EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToProducts(Product product)
 {
     base.AddObject("Products", product);
 }
示例#4
0
 /// <summary>
 /// Create a new Product object.
 /// </summary>
 /// <param name="id">Initial value of the Id property.</param>
 /// <param name="image">Initial value of the Image property.</param>
 /// <param name="mimeType">Initial value of the MimeType property.</param>
 /// <param name="name">Initial value of the Name property.</param>
 /// <param name="length">Initial value of the Length property.</param>
 /// <param name="width">Initial value of the Width property.</param>
 /// <param name="modifiedDate">Initial value of the ModifiedDate property.</param>
 public static Product CreateProduct(global::System.Int32 id, global::System.Byte[] image, global::System.String mimeType, global::System.String name, global::System.Decimal length, global::System.Decimal width, global::System.DateTime modifiedDate)
 {
     Product product = new Product();
     product.Id = id;
     product.Image = image;
     product.MimeType = mimeType;
     product.Name = name;
     product.Length = length;
     product.Width = width;
     product.ModifiedDate = modifiedDate;
     return product;
 }
示例#5
0
        public ActionResult Delete(int Id, Product product)
        {
            try
            {
                Product productToDelete = _repository.Get(Id);
                _repository.Delete(Id, productToDelete);

                var productViewModel = new ProductViewModel
                                           {
                                               Id = productToDelete.Id,
                                               Image = productToDelete.Image,
                                               MimeType = productToDelete.MimeType,
                                               Name = productToDelete.Name,
                                               Description = productToDelete.Description,
                                               Length = productToDelete.Length,
                                               Width = productToDelete.Width,
                                               Material = productToDelete.Material,
                                               ModifiedDate = productToDelete.ModifiedDate
                                           };
                return RedirectToAction("Index", productViewModel);
            }
            catch
            {
                return View();
            }
        }
示例#6
0
        public void UploadOrUpdateProduct(string fileName, string mimeType, byte[] image, string description,
                                          decimal length, decimal width, string material)
        {
            Product product = (_dataContext.Products.Where(imageStore => imageStore.Image == image)).FirstOrDefault();

            if (product == null)
            {
                var prod = new Product
                               {
                                   Id = PrimaryKeyUtil.RandomNumber(1, 100903),
                                   Name = fileName,
                                   MimeType = mimeType,
                                   Image = image,
                                   Description = description,
                                   Length = length,
                                   Width = width,
                                   Material = material,
                                   ModifiedDate = DateTime.Now
                               };
                _dataContext.Products.AddObject(prod);
            }
            else
            {
                product.Image = image;
                product.MimeType = mimeType;
                product.Name = fileName;
                product.Description = description;
                product.Length = length;
                product.Width = width;
                product.Material = material;
                product.ModifiedDate = DateTime.Now;
            }
            _dataContext.SaveChanges();
        }