コード例 #1
0
        public ActionResult Create([Bind(Include = "RoomName,RoomId,RoomStatus,BedSize,Price")] Room room)
        {
            if (ModelState.IsValid)
            {
                db.Rooms.Add(room);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(room));
        }
コード例 #2
0
        public ActionResult Create([Bind(Include = "RezervationId,RoomName,CheckInDate,CheckOutDate,AdultNumber,ChildrenNumber")] Rezervation rezervation)
        {
            if (ModelState.IsValid)
            {
                db.Rezervations.Add(rezervation);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(rezervation));
        }
コード例 #3
0
        public ActionResult Create([Bind(Include = "HotelName,Id,CityName")] Hotel hotel)
        {
            if (ModelState.IsValid)
            {
                db.Hotels.Add(hotel);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.CityName = new SelectList(db.Cities, "CityName", "CityName", hotel.CityName);
            return(View(hotel));
        }
コード例 #4
0
 public ActionResult BlogEkle(Blog b, HttpPostedFileBase file)
 {
     try
     {
         using (MacarenaDBContext context = new MacarenaDBContext())
         {
             Blog _blog = new Blog();
             if (file != null && file.ContentLength > 0)
             {
                 MemoryStream memoryStream = file.InputStream as MemoryStream;
                 if (memoryStream == null)
                 {
                     memoryStream = new MemoryStream();
                     file.InputStream.CopyTo(memoryStream);
                 }
                 _blog.BlogFoto = memoryStream.ToArray();
             }
             _blog.BlogBaslik = b.BlogBaslik;
             _blog.BlogIcerik = b.BlogIcerik;
             _blog.Tarih      = DateTime.Now;
             context.Blog.Add(_blog);
             context.SaveChanges();
             return(RedirectToAction("Blog", "Admin"));
         }
     }
     catch (Exception ex)
     {
         throw new Exception("Eklerken hata oluştu");
     }
 }
コード例 #5
0
 public ActionResult BlogDuzenle(Blog b, HttpPostedFileBase file)
 {
     try
     {
         using (MacarenaDBContext context = new MacarenaDBContext())
         {
             var _blogDuzenle = context.Blog.Where(x => x.ID == b.ID).FirstOrDefault();
             if (file != null && file.ContentLength > 0)
             {
                 MemoryStream memoryStream = file.InputStream as MemoryStream;
                 if (memoryStream == null)
                 {
                     memoryStream = new MemoryStream();
                     file.InputStream.CopyTo(memoryStream);
                 }
                 _blogDuzenle.BlogFoto = memoryStream.ToArray();
             }
             _blogDuzenle.BlogBaslik = b.BlogBaslik;
             _blogDuzenle.BlogIcerik = b.BlogIcerik;
             _blogDuzenle.Tarih      = DateTime.Now;
             context.SaveChanges();
             return(RedirectToAction("Blog", "Admin"));
         }
     }
     catch (Exception ex)
     {
         throw new Exception("Güncellerken hata oluştu " + ex.Message);
     }
 }
コード例 #6
0
 public ActionResult BlogSil(int BlogID)
 {
     try
     {
         using (MacarenaDBContext context = new MacarenaDBContext())
         {
             context.Blog.Remove(context.Blog.First(d => d.ID == BlogID));
             context.SaveChanges();
             return(RedirectToAction("Blog", "Admin"));
         }
     }
     catch (Exception ex)
     {
         throw new Exception("Silerken hata oluştu", ex.InnerException);
     }
 }