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(); }
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(); }
/// <summary> /// Deprecated Method for adding a new object to the Products EntitySet. Consider using the .Add method of the associated ObjectSet<T> property instead. /// </summary> public void AddToProducts(Product product) { base.AddObject("Products", product); }
/// <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; }
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(); } }
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(); }