public ActionResult Edit([Bind(Include = "Id,Name,Email")] Customer customer)
 {
     if (ModelState.IsValid)
     {
         db.Entry(customer).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(customer));
 }
Esempio n. 2
0
        public ActionResult Create([Bind(Include = "Id,Description")] Room room)
        {
            if (ModelState.IsValid)
            {
                db.Rooms.Add(room);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(room));
        }
        public bool DeleteStayType(StayType stayType)
        {
            var context = new HotelBookingContext();

            context.Entry(stayType).State = System.Data.Entity.EntityState.Deleted;

            return(context.SaveChanges() > 0);
        }
        public bool SaveStayType(StayType stayType)
        {
            var context = new HotelBookingContext();

            context.StayTypes.Add(stayType);

            return(context.SaveChanges() > 0);
        }
Esempio n. 5
0
        public void Remove(int id)
        {
            // The Single method below throws an InvalidOperationException
            // if there is not exactly one room with the specified Id.
            var room = db.Room.Single(r => r.Id == id);

            db.Room.Remove(room);
            db.SaveChanges();
        }
        public ActionResult Index()
        {
            using (var ctx = new HotelBookingContext())
            {
                var hotel = new Hotel()
                {
                    Name = "Bill Bill"
                };

                ctx.Hotels.Add(hotel);
                ctx.SaveChanges();
            }
            ViewBag.Title = "Home Page";

            return(View());
        }
Esempio n. 7
0
 public Customer Add(Customer entity)
 {
     db.Add(entity);
     db.SaveChanges();
     return(entity);
 }
 public void Add(Customer entity)
 {
     db.Customer.Add(entity);
     db.SaveChanges();
 }
 public void Add(Room entity)
 {
     db.Room.Add(entity);
     db.SaveChanges();
 }
Esempio n. 10
0
        public void Add(Booking entity)
        {
            var newBooking = db.Booking.Add(entity);

            db.SaveChanges();
        }
Esempio n. 11
0
 public void Save()
 {
     db.SaveChanges();
 }
Esempio n. 12
0
 public Booking Add(Booking entity)
 {
     db.Booking.Add(entity);
     db.SaveChanges();
     return(null);
 }
Esempio n. 13
0
 public Room Add(Room entity)
 {
     db.Add(entity);
     db.SaveChanges();
     return(entity);
 }