public bool Delete(Guid id) { PdbBanner itemc = _context.PdbBanners.SingleOrDefault(item => item.ID == id); _context.PdbBanners.DefaultIfEmpty(itemc); _context.Entry(itemc).State = System.Data.Entity.EntityState.Deleted; return(_context.SaveChanges() == 1); }
public ActionResult Edit(PdbBanner met) { if (ModelState.IsValid) { bool check = this._repos.Edit(met); if (check) { ModelState.AddModelError("", "Edit successful"); } else { return(RedirectToAction("Edit")); } } return(View()); }
public ActionResult Add(PdbBanner ban, HttpPostedFileBase file) { if (file != null) { ban.ID = Guid.NewGuid(); //string pic = System.IO.Path.GetFileName(file.FileName); //string path = System.IO.Path.Combine(Server.MapPath("~/images/profile"), pic); //// file is uploaded //file.SaveAs(path); // save the image path path to the database or you can send image // directly to database // in-case if you want to store byte[] ie. for DB using (MemoryStream ms = new MemoryStream()) { file.InputStream.CopyTo(ms); byte[] array = ms.GetBuffer(); ban.ImageName = array; } if (ModelState.IsValid) { bool check = this._repos.Create(ban); if (check) { ModelState.AddModelError("", "Create Successful !"); } else { return(RedirectToAction("Add")); } } } else { ModelState.AddModelError("", "Bạn Chưa Chọn hình!"); } return(View()); }
public ActionResult Edit(Guid id) { PdbBanner met = this._repos.GetOne(id); return(View(met)); }
public ActionResult Details(Guid id) { PdbBanner mete = this._repos.GetOne(id); return(View(mete)); }
public bool Edit(PdbBanner met) { _context.PdbBanners.Attach(met); _context.Entry(met).State = System.Data.Entity.EntityState.Modified; return(_context.SaveChanges() == 1);; }
public bool Create(PdbBanner ban) { _context.PdbBanners.Add(ban); _context.Entry(ban).State = System.Data.Entity.EntityState.Added; return(_context.SaveChanges() == 1); }