public void SuaVideoCaThe(CaThe cathe) { CaThe model = db.CaThes.Find(cathe.MaCaThe); model.Video = cathe.Video; db.SaveChanges(); }
public ActionResult Them(CaThe model, HttpPostedFileBase fileVideo) { model.NgaySinh = DateTime.Parse(Request.Form["NgaySinh"]); model.Video = DateTime.Now.Ticks + fileVideo.FileName; if (fileVideo.ContentLength > 0) { var fileName = Path.GetFileName(fileVideo.FileName); var path = Path.Combine(Server.MapPath("~/assets/client/videos/"), DateTime.Now.Ticks + fileName); fileVideo.SaveAs(path); } if (Session["fileUpload"] != null) { string _fileName; string listImages = ""; fileUpload = (List <HttpPostedFileBase>)Session["fileUpload"]; foreach (var item in fileUpload) { string pic = Path.GetFileName(item.FileName).Substring(0, Path.GetFileName(item.FileName).IndexOf(".")); _fileName = pic + ".jpg"; var path = Path.Combine(Server.MapPath("~/assets/client/images/"), _fileName); item.SaveAs(path); listImages += _fileName + "|"; } model.HinhAnh = listImages; model.TinhTrang = "Sẵn bán"; var dao = new AdminDAO(); dao.ThemCaThe(model); Session["fileUpload"] = null; } return(RedirectToAction("CaThe", new { MaLoai = model.MaLoai, message = "Thêm cá thể thành công" })); }
//public List<CaThe> GetAllCaThe_MaLoai(int MaLoai) { // return db.CaThes.Where(x => x.MaLoai == MaLoai).ToList(); //} //public List<CaThe> GetNewCaThe() { // return db.CaThes.OrderByDescending(x => x.MaCaThe).Take(3).ToList(); //} //public string GetTenLoai_MaLoai(int MaLoai) { // var model = db.Loais.Find(MaLoai); // return model.TenLoai; //} //public CaThe GetCaThe_MaLoai_MaCaThe(int MaLoai, int MaCaThe) { // return db.CaThes.Where(x => x.MaLoai == MaLoai && x.MaCaThe == MaCaThe).FirstOrDefault(); //} //public List<CaThe> TimCaThe(string ten) { // return db.CaThes.Where(x => x.TenCaThe.Contains(ten)).ToList(); //} public void BanCaThe(int MaCaThe) { CaThe cathe = db.CaThes.Find(MaCaThe); cathe.TinhTrang = "Đã bán"; db.SaveChanges(); }
public ActionResult SuaCaThe(CaThe cathe, HttpPostedFileBase fileVideo) { cathe.NgaySinh = DateTime.Parse(Request.Form["NgaySinh"]); string tinhtrang = Request.Form["tinhtrang"]; cathe.TinhTrang = tinhtrang; new AdminDAO().SuaCaThe(cathe); return(RedirectToAction("CaThe", new { MaLoai = cathe.MaLoai, message = "Sửa cá thể thành công" })); }
public ActionResult SuaVideoCaThe(CaThe cathe, HttpPostedFileBase fileVideo) { if (fileVideo.ContentLength > 0) { cathe.Video = DateTime.Now.Ticks + fileVideo.FileName; var fileName = Path.GetFileName(fileVideo.FileName); var path = Path.Combine(Server.MapPath("~/assets/client/videos/"), DateTime.Now.Ticks + fileName); fileVideo.SaveAs(path); new AdminDAO().SuaVideoCaThe(cathe); } return(RedirectToAction("CaThe", new { MaLoai = cathe.MaLoai, message = "Sửa Video thành công" })); }
public void SuaCaThe(CaThe cathe) { CaThe model = db.CaThes.Find(cathe.MaCaThe); model.TenCaThe = cathe.TenCaThe; model.MoTa = cathe.MoTa; model.NgaySinh = cathe.NgaySinh; model.GiaBan = cathe.GiaBan; model.GiaMua = cathe.GiaMua; model.KhuyenMai = cathe.KhuyenMai; model.TinhTrang = cathe.TinhTrang; db.SaveChanges(); }
public void ThemCaThe(CaThe model) { db.CaThes.Add(model); db.SaveChanges(); }
public void AddCaThe(CaThe cathe) { CaTheRepo.Add(cathe); }