Пример #1
0
        public ActionResult Insert(BRAND entity, HttpPostedFileBase file)
        {
            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);

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

                var  th  = new BrandModel();
                bool res = th.insertBrand(entity);
                if (res)
                {
                    return(RedirectToAction("Insert", "Brand", new { type = "success" }));
                }
                else
                {
                    return(RedirectToAction("Insert", "Brand", new { type = "fail" }));
                }
            }
            return(View(entity));
        }