public ActionResult EditDrzewoAlejowe(int productID) { DrzewoAlejowe drzewoalejowe = drzewoAlejoweRepository.DrzewaAlejowe.FirstOrDefault(d => d.ProductID == productID); //drzewoalejowe.Date = DateTime.Now; return(View(drzewoalejowe)); }
public ActionResult CreateDrzewoAlejowe() { var drzewoAlejowe = new DrzewoAlejowe(); drzewoAlejowe.Date = DateTime.Now; drzewoAlejowe.Available = true; return(View("EditDrzewoAlejowe", drzewoAlejowe)); }
public DrzewoAlejowe DeleteDrzewoAlejowe(int drzewoAlejoweID) { DrzewoAlejowe dbEntry = context.DrzewaAlejowe.Find(drzewoAlejoweID); if (dbEntry != null) { context.DrzewaAlejowe.Remove(dbEntry); context.SaveChanges(); } return(dbEntry); }
public FileContentResult GetImage(int productID) { DrzewoAlejowe drzewoAlejowe = repository.DrzewaAlejowe.FirstOrDefault(p => p.ProductID == productID); if (drzewoAlejowe != null) { return(File(drzewoAlejowe.ImageData, drzewoAlejowe.ImageMimeType)); } else { return(null); } }
public ActionResult Details(int?productID) { if (productID == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } DrzewoAlejowe drzewoAlejowe = repository.DrzewaAlejowe.FirstOrDefault(k => k.ProductID == productID); if (drzewoAlejowe == null) { return(HttpNotFound()); } return(View(drzewoAlejowe)); }
public ActionResult EditDrzewoAlejowe(DrzewoAlejowe drzewoAlejowe, HttpPostedFileBase image = null) { if (ModelState.IsValid) { if (image != null) { drzewoAlejowe.ImageMimeType = image.ContentType; drzewoAlejowe.ImageData = new byte[image.ContentLength]; image.InputStream.Read(drzewoAlejowe.ImageData, 0, image.ContentLength); } drzewoAlejoweRepository.SaveDrzewoAlejowe(drzewoAlejowe); TempData["message"] = string.Format("Zapisano {0} ", drzewoAlejowe.Name); return(RedirectToAction("DrzewoAlejoweList")); } else { return(View(drzewoAlejowe)); } }
public void SaveDrzewoAlejowe(DrzewoAlejowe drzewoAlejowe) { if (drzewoAlejowe.ProductID == 0) { context.DrzewaAlejowe.Add(drzewoAlejowe); } else { DrzewoAlejowe dbEntry = context.DrzewaAlejowe.Find(drzewoAlejowe.ProductID); if (dbEntry != null) { //Product dbEntry.Name = drzewoAlejowe.Name; dbEntry.Date = drzewoAlejowe.Date; dbEntry.Description = drzewoAlejowe.Description; dbEntry.Price = drzewoAlejowe.Price; dbEntry.Discount = drzewoAlejowe.Discount; dbEntry.Description = drzewoAlejowe.Description; dbEntry.Available = drzewoAlejowe.Available; if (dbEntry.Available == true) { dbEntry.Quantity = drzewoAlejowe.Quantity; } else { dbEntry.Quantity = null; } dbEntry.HeightMin = drzewoAlejowe.HeightMin; dbEntry.HeightMax = drzewoAlejowe.HeightMax; dbEntry.ImageData = drzewoAlejowe.ImageData; dbEntry.ImageMimeType = drzewoAlejowe.ImageMimeType; //DrzewoAlejowe dbEntry.WidthMin = drzewoAlejowe.WidthMin; dbEntry.WidthMax = drzewoAlejowe.WidthMax; } } context.SaveChanges(); }