Esempio n. 1
0
        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());
                }
            }
        }
Esempio n. 2
0
 public ActionResult Main(Aparts apart)
 {
     if (Session["UserID"] == Session["ApartUserID"])
     {
         return(View(apartrepository.GetAparts()));
     }
     else
     {
         return(RedirectToAction("Login"));
     }
 }
Esempio n. 3
0
 public ActionResult Find(string Type, Aparts apart)
 {
     search = Type;
     return(RedirectToAction("SearchInAparts"));
 }
Esempio n. 4
0
        public ActionResult AddApartByUser(int id = 0)
        {
            Aparts apart = new Aparts();

            return(View(apart));
        }