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)); }
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)); }
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)); }
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"); } }
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); } }
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); } }