public ActionResult HOMEEDIT([Bind(Include = "ID,TUADE1,TUADE2,TUADE3,TENNUT,HINHANHNEN,HINHANHNENFile")] HOME SUAHOME) { var dulieuHOME = new BAULEPROFOLIOEntities2(); // anh tạo 1 chuổi dulieucoán anh gọi nguyên cái DB của em lại. đổ vào đó var HINHANHCUAHOME = dulieuHOME.HOMEs.Single(e => e.ID == SUAHOME.ID); // sau đó anh dùng biến HINHANHcosan để hứng dữ liệu model tại nơi mà ID của nó bằng ID của thằng SUAMODEL, để lấy ra đúng cái hình if (SUAHOME.HINHANHNENFile == null) // nếu file nó null { SUAHOME.HINHANHNEN = HINHANHCUAHOME.HINHANHNEN; //nó sẽ fill dữ liệu từ data vào lại để edit } else { string fileName = Path.GetFileNameWithoutExtension(SUAHOME.HINHANHNENFile.FileName); string extension = Path.GetExtension(SUAHOME.HINHANHNENFile.FileName); fileName = fileName + DateTime.Now.ToString("yymmssfff") + extension; SUAHOME.HINHANHNEN = fileName; fileName = Path.Combine(Server.MapPath("~/ContentWebmaster/img/"), fileName);//coi kỹ lại chỗ này nha. SUAHOME.HINHANHNENFile.SaveAs(fileName); } if (ModelState.IsValid) { db.Entry(SUAHOME).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("HOMEVIEW")); } return(View(SUAHOME)); }
public ActionResult HOMEEDIT(string id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } HOME SUAHOME = db.HOMEs.Find(id); if (SUAHOME == null) { return(HttpNotFound()); } return(View(SUAHOME)); }
public static HomeView convertToModelView(HOME home) { HomeView homeView = new HomeView(); homeView.BankCode = home.BankCode; homeView.oneMonth = home.oneMonth; homeView.twoMonth = home.twoMonth; homeView.threeMonth = home.threeMonth; homeView.sixMonth = home.sixMonth; homeView.nineMonth = home.nineMonth; homeView.twelveMonth = home.twelveMonth; homeView.twentyfourMonth = home.twentyfourMonth; homeView.thirtysixMonth = home.thirtysixMonth; homeView.fortyeightMonth = home.fortyeightMonth; homeView.sixtyMonth = home.sixtyMonth; return(homeView); }