public ActionResult UploadH2(BaiDang viewModel, HttpPostedFileBase file) { if (file != null) { string path = Path.Combine(Server.MapPath("~/Image"), Path.GetFileName(file.FileName)); file.SaveAs(path); string s = "/Image/" + Path.GetFileName(file.FileName); viewModel.hinhanh = s; } UserLogin a = (UserLogin)Session[CommonConstrants.USER_SESSION]; var BDsum = new BaiDangDAO(); viewModel.mataikhoan = a.ID; convert(viewModel); return(View("TrangSua", viewModel)); }
public ActionResult create(BaiDang bd) { UserLogin a = (UserLogin)Session[CommonConstrants.USER_SESSION]; //bd_create = bd; var BDsum = new BaiDangDAO(); BaiDang bd_temp = new BaiDang(); bd.mataikhoan = a.ID; bd_temp.ten = null; string TacGia = Request.Form["TacGia"]; string NXB = Request.Form["NXB"]; string tenTheLoai = Request.Form["TheLoai"]; if (BDsum.insertBaiDang(bd)) { Response.Write("<script type=\"text/javascript\">alert('Tạo Bài đăng thành công !!! ');</script>"); return(View("create", bd_temp)); } else { // img_create = null; return(View("create", bd_temp)); } }
public ActionResult UploadH(BaiDang viewModel, HttpPostedFileBase file) { if (file != null) { string path = Path.Combine(Server.MapPath("~/Image"), Path.GetFileName(file.FileName)); file.SaveAs(path); string s = "/Image/" + Path.GetFileName(file.FileName); viewModel.hinhanh = s; } UserLogin a = (UserLogin)Session[CommonConstrants.USER_SESSION]; var BDsum = new BaiDangDAO(); viewModel.mataikhoan = a.ID; string TacGia = Request.Form["TacGia"]; string NXB = Request.Form["NXB"]; string tenTheLoai = Request.Form["TheLoai"]; if (TacGia != null) { TacGia tempTG = new TacGia(); tempTG = BDsum.getTacGiabyTen(TacGia); if (tempTG != null) { viewModel.setTG(tempTG); } else { if (BDsum.insertTacGia(TacGia)) { tempTG = BDsum.getTacGiabyTen(TacGia); viewModel.setTG(tempTG); } else { Response.Write("<script type=\"text/javascript\">alert('Insert tác giả không thành công!!! ');</script>"); } } } if (NXB != null) { NhaXuatBan tempTG = new NhaXuatBan(); tempTG = BDsum.getNXBbyTen(NXB); if (tempTG != null) { viewModel.NhaXuatBan = tempTG; } else { if (BDsum.insertNXB(NXB)) { tempTG = BDsum.getNXBbyTen(NXB); viewModel.NhaXuatBan = tempTG; } else { Response.Write("<script type=\"text/javascript\">alert('Insert NXB không thành công!!! ');</script>"); } } } if (tenTheLoai != null) { TheLoai tempTG = new TheLoai(); tempTG = BDsum.getTheloaibyTen(tenTheLoai); if (tempTG != null) { viewModel.TheLoai = tempTG; } else { if (BDsum.insertTheLoai(tenTheLoai)) { tempTG = BDsum.getTheloaibyTen(tenTheLoai); viewModel.TheLoai = tempTG; } else { Response.Write("<script type=\"text/javascript\">alert('Insert TheLoai không thành công!!! ');</script>"); } } } if (BDsum.insertBaiDang(viewModel)) { Response.Write("<script type=\"text/javascript\">alert('Tạo Bài đăng thành công !!! ');</script>"); return(View("Index", BDsum.getListBaiDang2(a.ID))); } else { Response.Write("<script type=\"text/javascript\">alert('Tạo Bài đăng ko thành công !!! ');</script>"); return(View("create", viewModel)); } }