示例#1
0
        public bool AddOccupannts(OccupantViewModel model)
        {
            try
            {
                HostelOccupant occupant = new HostelOccupant
                {
                    FirstName     = model.Firstname,
                    Surname       = model.Surname,
                    DateOfBirth   = model.DateOfBirth,
                    Gender        = model.Gender,
                    MaritalStatus = model.MaritalStatus,
                    PhoneNumber   = model.PhoneNumber,
                    RoomId        = model.RoomID
                };



                _context.HostelOccupant.Add(occupant);
                _context.SaveChanges();
                return(true);
            }
            catch (Exception)
            {
                return(false);
            }
        }
示例#2
0
        public bool AddRoom(RoomViewModel model)
        {
            try
            {
                Room room = new Room
                {
                    //Price = model.Price,
                    RoomNumber  = model.RoomNumber,
                    IsAvailable = model.IsAvailable,
                    FloorId     = model.FloorID,
                    // room.HostelId = (int)model.HostelID;
                    RoomTypeId = model.RoomTypeID
                };



                _context.Room.Add(room);
                _context.SaveChanges();
                return(true);
            }
            catch (Exception)
            {
                return(false);
            }
        }
示例#3
0
        public bool AddFloor(FloorViewModel model)
        {
            try
            {
                Floor floor = new Floor();
                floor.FloorName = model.FloorName;

                _context.Floor.Add(floor);
                _context.SaveChanges();

                return(true);
            }
            catch (Exception)
            {
                return(false);
            }
        }
示例#4
0
        public bool AddRoomType(RoomTypeViewModel model)
        {
            try
            {
                RoomType roomtype = new RoomType();
                roomtype.Type     = model.Type;
                roomtype.Capacity = model.Capacity;

                _context.RoomType.Add(roomtype);
                _context.SaveChanges();

                return(true);
            }
            catch (Exception)
            {
                return(false);
            }
        }
示例#5
0
        public bool AddBooking(BookingViewModel model)
        {
            try
            {
                BookingDetails booking = new BookingDetails
                {
                    ArrivalDate   = model.ArrivalDate,
                    DepartureDate = model.DepartureDate,
                    RoomId        = model.RoomID,
                    Price         = model.Price
                };

                _context.BookingDetails.Add(booking);
                _context.SaveChanges();
                return(true);
            }
            catch (Exception)
            {
                return(false);
            }
        }