public ActionResult Brands(tbl_Marka Brand, HttpPostedFileBase Brand_image) { if (Brand_image != null && Brand_image.ContentLength > 0) { string File = System.IO.Path.GetFileName(Brand_image.FileName); string GuidKey = Guid.NewGuid().ToString(); string fileExt = Path.GetExtension(Brand_image.FileName); Brand.Marka_logo = GuidKey + fileExt; var uploadurl = ftp_Brand; var uploadfilename = GuidKey + fileExt; Stream streamObj = Brand_image.InputStream; byte[] buffer = new byte[Brand_image.ContentLength]; streamObj.Read(buffer, 0, buffer.Length); streamObj.Close(); streamObj = null; string ftpurl = String.Format("{0}/{1}", uploadurl, uploadfilename); var requestObj = FtpWebRequest.Create(ftpurl) as FtpWebRequest; requestObj.Method = WebRequestMethods.Ftp.UploadFile; requestObj.Credentials = new NetworkCredential(ftpuser, pasword); Stream requestStream = requestObj.GetRequestStream(); requestStream.Write(buffer, 0, buffer.Length); requestStream.Flush(); requestStream.Close(); requestObj = null; } if (Data.Data.saveBrand(Brand) == false) { ViewBag.Error = "Lütfen Bilgilerinizi Kontrol Ediniz."; return(RedirectToAction("Error", "Default")); } return(RedirectToAction("Brands", "Admin")); }
public static bool saveBrand(tbl_Marka _Brands) { bool _result = true; using (seckinkirtasiyeEntities db = new seckinkirtasiyeEntities()) { try { if (_Brands.Marka_ID == 0) { db.tbl_Marka.Add(_Brands); } else { db.tbl_Marka.Attach(_Brands); db.Entry(_Brands).State = System.Data.Entity.EntityState.Modified; } db.SaveChanges(); } catch (Exception) { _result = false; } } return(_result); }
public ActionResult Ekle(tbl_Marka marka) { uow.MarkaRepository.Add(new tbl_Marka { Marka_Adi = marka.Marka_Adi }); uow.SaveChanges(); return(RedirectToAction("Liste")); }
public ActionResult Slide_Brand(int brand_id) { tbl_Marka _deletebrand = (from p in db.tbl_Marka where p.Marka_ID == brand_id select p).SingleOrDefault(); int proid = _deletebrand.Marka_ID; db.tbl_Marka.Remove(_deletebrand); db.SaveChanges(); return(RedirectToAction("Brands", "Admin")); }
public ActionResult Duzenle(tbl_Marka marka) { if (ModelState.IsValid) { uow.MarkaRepository.Update(marka); uow.SaveChanges(); return(RedirectToAction("Liste")); } return(View(marka)); }
public ActionResult Brands(int?id) { if (Session["UserID"] == null) { return(RedirectToAction("Login", "Admin")); } if (RouteData.Values["id"] != null) { ViewBag.UpdateBrand = "True"; int _id = Convert.ToInt32(RouteData.Values["id"]); tbl_Marka _Brand = Data.Data.get_brand(id); ViewBag.Brand_Image = _Brand.Marka_logo; ViewBag.Brand_Name = _Brand.Marka_name; return(View(_Brand)); } return(View()); }