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));
 }
Exemplo 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);
        }
Exemplo 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();
        }
Exemplo n.º 6
0
        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());
        }
Exemplo 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();
 }
Exemplo n.º 9
0
 public void Add(Room entity)
 {
     db.Room.Add(entity);
     db.SaveChanges();
 }
Exemplo n.º 10
0
        public void Add(Booking entity)
        {
            var newBooking = db.Booking.Add(entity);

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