示例#1
0
 public void Add(params T[] items)
 {
     foreach (T item in items)
     {
         _context.Entry(item).State = EntityState.Added;
     }
     _context.SaveChanges();
 }
示例#2
0
        public IActionResult Delete(long id)
        {
            var todo = _context.Reservations.Find(id);

            if (todo == null)
            {
                return(NotFound());
            }

            _context.Reservations.Remove(todo);
            _context.SaveChanges();
            return(NoContent());
        }
示例#3
0
        public RoomController(RoomBookingContext context)
        {
            _context = context;

            if (_context.Rooms.Count() == 0)
            {
                _context.Rooms.Add(new Room
                {
                    Location = "A302",
                    Floor    = 3,
                    Size     = 6,
                    Type     = RoomType.Group
                });
                _context.SaveChanges();
            }
        }
示例#4
0
        public IActionResult Booking(RoomReservationModel Model)
        {
            RoomReservationModel roomReservation = new RoomReservationModel();
            var roomDetails = GetRooms().Where(r => r.RoomId == Model.RoomId).FirstOrDefault();

            roomReservation.HotelId             = roomDetails.HotelsModel.HotelId;
            roomReservation.RoomId              = roomDetails.RoomId;
            roomReservation.Rate                = roomDetails.PricePerNight;
            roomReservation.CheckIn             = Model.CheckIn;
            roomReservation.CheckOut            = Model.CheckOut;
            roomReservation.Guests              = 1;
            roomReservation.UserId              = GetUserId();
            roomReservation.TotalBillAmount     = Model.TotalBillAmount;
            roomReservation.RoomReservationDate = DateTime.Now;
            _bokingDBContext.Add(roomReservation);
            _bokingDBContext.SaveChanges();
            SendEmail(GetUserId(), roomDetails.HotelsModel.HotelName, roomDetails.PricePerNight, roomDetails.Beds, Model.CheckIn, Model.CheckOut, Model.TotalBillAmount);
            return(RedirectToAction("Confirmation"));
        }
        public async Task <IActionResult> Create(UserModel model)
        {
            try
            {
                model.Isactive = true;
                _bokingDBContext.Add(model);
                _bokingDBContext.SaveChanges();

                var claims = new List <Claim>
                {
                    new Claim(ClaimTypes.Name, model.Username),
                    new Claim(ClaimTypes.Upn, model.UserId.ToString())
                };

                var claimsIdentity = new ClaimsIdentity(
                    claims, CookieAuthenticationDefaults.AuthenticationScheme);

                var authProperties = new AuthenticationProperties
                {
                    AllowRefresh = false,
                    ExpiresUtc   = DateTimeOffset.UtcNow.AddMinutes(60),
                    IsPersistent = false,
                    IssuedUtc    = DateTime.Now
                };

                await HttpContext.SignInAsync(
                    CookieAuthenticationDefaults.AuthenticationScheme,
                    new ClaimsPrincipal(claimsIdentity),
                    authProperties);
            }
            catch (Exception ex)
            {
                return(RedirectToAction("Error", "Rooms", new { ErrorMessage = ex.Message }));
            }

            return(RedirectToAction("Index", "Rooms"));
        }
示例#6
0
 public bool Create(Room room)
 {
     context.Rooms.Add(room);
     return(context.SaveChanges() > 0);
 }
 public void Save()
 {
     db.SaveChanges();
 }
示例#8
0
 public bool Create(Booking booking)
 {
     context.Bookings.Add(booking);
     return(context.SaveChanges() > 0);
 }