public ActionResult Edit(DB.Products Ilan) { if (Ilan.ProductImageName1 == null) { Ilan.ProductImageName1 = ""; } var productImagePath = string.Empty; if (Request.Files != null && Request.Files.Count > 0) { var file = Request.Files[0]; if (file.ContentLength > 0) { var folder = Server.MapPath("~/images/upload/Product"); var fileName = Guid.NewGuid() + ".jpg"; file.SaveAs(Path.Combine(folder, fileName)); var filePath = "images/upload/Product/" + fileName; productImagePath = filePath; } } if (Ilan.Id > 0) { var dbIlan = emlakDBEntities.Products.FirstOrDefault(x => x.Id == Ilan.Id); dbIlan.Category_Id = (int)Ilan.CategoryID; dbIlan.CategoryID = Ilan.CategoryID; dbIlan.ModifiedDate = DateTime.Now; dbIlan.Description = Ilan.Description; dbIlan.Name = Ilan.Name; dbIlan.Price = Ilan.Price; dbIlan.oda = Ilan.oda; dbIlan.kat = Ilan.kat; dbIlan.metreKare = Ilan.metreKare; dbIlan.Address = Ilan.Address; dbIlan.state = Ilan.state; System.Diagnostics.Debug.WriteLine("a" + Ilan.CategoryID + "a"); System.Diagnostics.Debug.WriteLine("b" + Ilan.Category_Id + "b"); if (string.IsNullOrEmpty(productImagePath) == false) { dbIlan.ProductImageName1 = productImagePath; } } else { Ilan.Category_Id = (int)Ilan.CategoryID; Ilan.CategoryID = (int)Ilan.CategoryID; Ilan.AddedDate = DateTime.Now; Ilan.kId = base.CurrentUserId(); emlakDBEntities.Entry(Ilan).State = System.Data.Entity.EntityState.Added; } emlakDBEntities.SaveChanges(); return(RedirectToAction("i")); }
public ilanEditModel() { Product = new DB.Products(); kategoriler = new List <SelectListItem>(); kategoriler = emlakDB.Categories.Select(x => new SelectListItem() { Text = x.Name, Value = x.Id.ToString() }).ToList(); }
public ActionResult Edit(DB.Products product) { if (IsLogon() == false) { return(RedirectToAction("index", "i")); } var productImagePath = string.Empty; if (Request.Files != null && Request.Files.Count > 0) { var file = Request.Files[0]; if (file.ContentLength > 0) { var folder = Server.MapPath("~/images/upload/Product"); var fileName = Guid.NewGuid() + ".jpg"; file.SaveAs(Path.Combine(folder, fileName)); var filePath = "images/upload/Product/" + fileName; productImagePath = filePath; } } if (product.Id > 0) { var dbProduct = context.Products.FirstOrDefault(x => x.Id == product.Id); dbProduct.Category_Id = product.Category_Id; dbProduct.ModifiedDate = DateTime.Now; dbProduct.Description = product.Description; dbProduct.IsContinued = product.IsContinued; dbProduct.Name = product.Name; dbProduct.Price = product.Price; dbProduct.UnitsInStock = product.UnitsInStock; dbProduct.IsDeleted = false; if (string.IsNullOrEmpty(productImagePath) == false) { dbProduct.ProductImageName = productImagePath; } } else { product.AddedDate = DateTime.Now; product.IsDeleted = false; product.ProductImageName = productImagePath; context.Entry(product).State = System.Data.Entity.EntityState.Added; } context.SaveChanges(); return(RedirectToAction("i")); }
public ActionResult Edit(DB.Products product) { var productImagePath = string.Empty; product.Description = string.Empty;//Ders 315'te ürünler sayfası boş geliyordu.Bu sorunnu gider.Giderince kontrol et.Ürnler>düzenle>Açıklama kısmı dolu gelecek bu durumda.O zaman dene işe yararsa bu satırı kaldır. if (Request.Files != null && Request.Files.Count > 0) { var file = Request.Files[0]; if (file.ContentLength > 0) { var folder = Server.MapPath("~/images/upload/Product"); var fileName = Guid.NewGuid() + ".jpg"; file.SaveAs(Path.Combine(folder, fileName)); var filePath = "images/upload/Product/" + fileName; productImagePath = filePath; } } if (product.Id > 0) { var dbProduct = context.Products.FirstOrDefault(x => x.Id == product.Id); dbProduct.Category_Id = product.Category_Id; dbProduct.ModifiedDate = DateTime.Now; dbProduct.Description = product.Description; dbProduct.IsContinued = product.IsContinued; dbProduct.Name = product.Name; dbProduct.Price = product.Price; dbProduct.UnitsInStock = product.UnitsInStock; dbProduct.IsDeleted = false; if (string.IsNullOrEmpty(productImagePath) == false) { dbProduct.ProductImageName = productImagePath; } } else { product.AddedDate = DateTime.Now; product.IsDeleted = false; product.ProductImageName = productImagePath; context.Entry(product).State = System.Data.Entity.EntityState.Added; } context.SaveChanges(); return(RedirectToAction("i")); }
public ProductModels() { Product = new DB.Products(); }
public Controller(DB.Products products) { ef = new DB.ProductServiceEntities(); Product = products; }