public ActionResult AddApartByUser(Aparts apartmodel, HttpPostedFileBase Image) { using (DbContext db = new DbContext()) { if (ModelState.IsValid) { if (Image != null) { byte[] imageData = null; using (var binaryReader = new BinaryReader(Image.InputStream)) { imageData = binaryReader.ReadBytes(Image.ContentLength); } apartmodel.ApartImage = imageData; } db.Aparts.Add(apartmodel); db.SaveChanges(); ViewBag.Message = "объявение" + " " + apartmodel.ApartType + " " + "успешно добавлено"; return(RedirectToAction("Main")); } else { return(View()); } } }
public ActionResult Main(Aparts apart) { if (Session["UserID"] == Session["ApartUserID"]) { return(View(apartrepository.GetAparts())); } else { return(RedirectToAction("Login")); } }
public ActionResult Find(string Type, Aparts apart) { search = Type; return(RedirectToAction("SearchInAparts")); }
public ActionResult AddApartByUser(int id = 0) { Aparts apart = new Aparts(); return(View(apart)); }