Ejemplo n.º 1
0
        public IHttpActionResult PutGuestlist(string id, Guestlist guestlist)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != guestlist.HotelName)
            {
                return(BadRequest());
            }

            db.Entry(guestlist).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!GuestlistExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
        public IHttpActionResult PutHotelRooms(int id, HotelRooms hotelRooms)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != hotelRooms.Hotel_No)
            {
                return(BadRequest());
            }

            db.Entry(hotelRooms).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!HotelRoomsExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
Ejemplo n.º 3
0
        static void Main(string[] args)
        {
            using (var context = new ViewsContext())
            {
                context.People.Add(new Person()
                {
                    Address = new Address
                    {
                        City   = "Warsaw",
                        Street = "Dubois"
                    },
                    Name    = "John",
                    Surname = "Kowalski"
                });
                context.SaveChanges();


                var people = context.Set <PeopleView>().AsQueryable().ToList();

                foreach (var view in people)
                {
                    Console.WriteLine($"{view.PersonId} {view.Name} {view.Surname} {view.City} {view.Street}");
                }
            }
        }