Esempio n. 1
0
        public void BrokedRoom(BrokedRoomDTO room)
        {
            try
            {
                string connectionString = ConfigurationManager.ConnectionStrings["ConnectToSQL"].ConnectionString;
                IRoomRepository repository = new RoomRepository(connectionString);

                NewRoom newRoom = new NewRoom();
                newRoom.Fio = room.Fio;
                newRoom.NumberPhone = room.NumberPhone;
                newRoom.Email = room.Email;
                newRoom.DescriptionRommId = room.DescriptionRommId;
                newRoom.DateFrom = room.DateFrom;
                newRoom.DateTo = room.DateTo;
                newRoom.Reserve = room.Reserve;

                repository.BrokedRoom(newRoom);

            }
            catch (Exception e)
            {
                Exception baseException = e.GetBaseException();
                throw new FaultException(e.Message);
            }
        }
Esempio n. 2
0
        public int GetId(int numRecord)
        {
            string connectionString = ConfigurationManager.ConnectionStrings["ConnectToSQL"].ConnectionString;
            IRoomRepository repository = new RoomRepository(connectionString);

            int _id = 0;
            int counter = 0;

            var rooms = repository.SelectAll();

            var roomDTOs = new List<RoomDTO>();

            foreach (var room in rooms)
            {
                counter++;
                roomDTOs.Add(new RoomDTO() { Id = room.Id, Name = room.Name, Price = room.Price, npp =  counter});
            }

            foreach (var item in roomDTOs)
            {
                if (item.npp == numRecord)
                {
                    _id = item.Id;
                    break;
                }
            }

            return _id;
        }
Esempio n. 3
0
        public RoomDTO[] GetRooms()
        {
            string connectionString = ConfigurationManager.ConnectionStrings["HotelDatabase"].ConnectionString;
            IRoomRepository repository = new RoomRepository(connectionString);

            var rooms = repository.GetRooms();

            var RoomDTOs = new List<RoomDTO>();

            foreach (var room  in rooms)
            {
                RoomDTOs.Add(new RoomDTO() { Id = room.Id, Number = room.Number, Quantity = room.Quantity, Reserved = room.Reserved });
            }

            return RoomDTOs.ToArray();
        }
Esempio n. 4
0
        public RoomDTO GetRowById(int id)
        {
            string connectionString = ConfigurationManager.ConnectionStrings["ConnectToSQL"].ConnectionString;
            IRoomRepository repository = new RoomRepository(connectionString);

            using (SqlConnection connection = new SqlConnection(connectionString))
            {
                connection.Open();
                using (SqlCommand command = new SqlCommand(queryGetAllId, connection))
                {
                    command.Parameters.AddWithValue("id", id);
                    using (SqlDataReader reader = command.ExecuteReader())
                    {
                        RoomDTO room = new RoomDTO();
                        if (reader.Read())
                        {
                            room = (new RoomDTO()
                            {
                                Id = (int)reader["id"],
                                Name = (string)reader["Name"],
                                Price = (int)reader["Price"]
                            });
                            return room;
                        }
                        else
                        {
                            return null;
                        }

                    }
                }
            }
        }
Esempio n. 5
0
        public RoomDTO[] SelectAll()
        {
            string connectionString = ConfigurationManager.ConnectionStrings["ConnectToSQL"].ConnectionString;
            IRoomRepository repository = new RoomRepository(connectionString);

            var rooms = repository.SelectAll();

            var roomDTOs = new List<RoomDTO>();

            foreach (var room in rooms)
            {
                roomDTOs.Add(new RoomDTO() { npp = room.npp, Id = room.Id, Name = room.Name, Price = room.Price });
            }

            return roomDTOs.ToArray();
        }