コード例 #1
0
ファイル: BrandController.cs プロジェクト: minhdinh365/BMW
        public ActionResult Edit(BRAND brand, HttpPostedFileBase file)
        {
            if (Session["Account"] == null)
            {
                return(RedirectToAction("Index", "Login", new { area = "" }));
            }
            else
            {
                if (ModelState.IsValid)
                {
                    if (file != null && file.ContentLength > 0)
                    {
                        string filename = System.IO.Path.GetFileName(file.FileName);
                        string urlfile  = Server.MapPath("~/Images/" + filename);
                        file.SaveAs(urlfile);

                        brand.HinhAnh = "/Images/" + filename;
                    }

                    var  th  = new BrandModel();
                    bool res = th.updateBrand(brand);
                    if (res)
                    {
                        return(RedirectToAction("Edit", "Brand", new { maTH = brand.MaTH, type = "success" }));
                    }
                }

                return(View(brand));
            }
        }