Пример #1
0
        public void SignU(string name, string login, string password, bookingContext db)
        {
            var id   = db.Users.OrderByDescending(u => u.Id).FirstOrDefault().Id + 1;
            var user = new User {
                Id = id, Name = name, Login = login, Password = password
            };

            db.Users.Add(user);
            db.SaveChanges();
        }
Пример #2
0
        void IReserve.Reserve(int?id, bookingContext db, string login)
        {
            User    user = db.Users.FirstOrDefault(u => u.Login == login);
            Room    room = db.Rooms.FirstOrDefault(r => r.Id == id);
            booking book = new booking();

            book.Idofroom           = id;
            book.Begindate          = UserBooking.bd;
            book.Enddate            = UserBooking.ed;
            book.Userid             = user.Id;
            book.IdofroomNavigation = room;
            book.User      = user;
            book.Idofhotel = room.HId;
            book.Id        = db.Bookings.Max(a => a.Id) + 1;

            db.Bookings.Add(book);
            db.SaveChanges();
        }