public ActionResult DeleteConfirmed(int id) { GeneralBusiness generalBusiness = db.GeneralBusinesses.Find(id); db.GeneralBusinesses.Remove(generalBusiness); db.SaveChanges(); return(RedirectToAction("Index")); }
public GeneralBusinessView() { GeneralBusiness gb = db.GeneralBusinesses.FirstOrDefault(); CompanyName = gb.CompanyName; Logo = gb.Logo; Slogan = gb.Slogan; Suburb = gb.Suburb.SubName; Description = gb.Description; FaxNo = gb.FaxNo; TelNo = gb.TelNo; EmailAddress = gb.EmailAddress; }
// GET: GeneralBusinesses/Delete/5 public ActionResult Delete(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } GeneralBusiness generalBusiness = db.GeneralBusinesses.Find(id); if (generalBusiness == null) { return(HttpNotFound()); } return(View(generalBusiness)); }
public ActionResult General() { GeneralBusiness gb = db.GeneralBusinesses.FirstOrDefault(); GeneralBusinessView view = new GeneralBusinessView(); view.CompanyBanner = gb.CompanyBanner; view.CompanyName = gb.CompanyName; view.Description = gb.Description; view.EmailAddress = gb.EmailAddress; view.FaxNo = gb.FaxNo; view.TelNo = gb.TelNo; view.Logo = gb.Logo; view.Suburb = gb.Suburb.SubName; return(View(gb)); }
// GET: GeneralBusinesses/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } GeneralBusiness generalBusiness = db.GeneralBusinesses.Find(id); if (generalBusiness == null) { return(HttpNotFound()); } ViewBag.Suburbs = new SelectList(db.Suburbs, "SuburbID", "SubName", generalBusiness.SuburbID); return(View(generalBusiness)); }
public ActionResult Create([Bind(Exclude = "CompanyBanner, Logo ", Include = "ID,CompanyName,Slogan,Description, SuburbID, TelNo, FaxNo, EmailAddress")] GeneralBusiness gb) { byte[] bannerData = null; if (Request.Files.Count > 0) { HttpPostedFileBase poImgFile = Request.Files["CompanyBanner"]; var image = poImgFile; using (var binary = new BinaryReader(poImgFile.InputStream)) { bannerData = binary.ReadBytes(poImgFile.ContentLength); } } byte[] logoData = null; if (Request.Files.Count > 0) { HttpPostedFileBase poImgFile = Request.Files["Logo"]; var image = poImgFile; using (var binary = new BinaryReader(poImgFile.InputStream)) { logoData = binary.ReadBytes(poImgFile.ContentLength); } } gb.Logo = logoData; gb.CompanyBanner = bannerData; if (ModelState.IsValid) { db.GeneralBusinesses.Add(gb); db.SaveChanges(); return(RedirectToRoute("Default", new { controller = "Manage", action = "Index" })); } return(View(gb)); }
public ActionResult Edit([Bind(Exclude = "CompanyBanner, Logo", Include = "ID,CompanyName,Slogan,Description, TelNo,FaxNo,SuburbID")] GeneralBusiness generalBusiness) { byte[] bannerData = null; if (Request.Files.Count > 0) { HttpPostedFileBase poImgFile = Request.Files["CompanyBanner"]; var image = poImgFile; using (var binary = new BinaryReader(poImgFile.InputStream)) { bannerData = binary.ReadBytes(poImgFile.ContentLength); } } byte[] logoData = null; if (Request.Files.Count > 0) { HttpPostedFileBase poImgFile = Request.Files["Logo"]; var image = poImgFile; using (var binary = new BinaryReader(poImgFile.InputStream)) { logoData = binary.ReadBytes(poImgFile.ContentLength); } } generalBusiness.Logo = logoData; generalBusiness.CompanyBanner = bannerData; if (ModelState.IsValid) { db.Entry(generalBusiness).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(generalBusiness)); }