         datePicker.locale = NSLocale(localeIdentifier: "PL")
         registerForKeyboardNotifications()
         self.navigationController?.navigationBar.translucent = false;
+    }
+    
+    func determineViewPurpose() {
+        if room == nil {
+            viewPurpose = RoomDetailsPurpose.Create
+        } else if room?.owner?.recordID == userRecordID && room?.didEnd == false {
+            viewPurpose = RoomDetailsPurpose.Edit
+        } else {
+            viewPurpose = RoomDetailsPurpose.View
+        }
     }
     
     deinit {

            limitSlider.value = Float(limit)
            privateSwitch.on = access == AccessType.Private ? true : false
        }
    }
    
    func createRoom() {

            room.restaurant = restaurant
        }
        
        if textFieldsAreFilled() {
            cloudKitHelper.editRoomRecord(room, completionHandler: {
                self.navigationController?.popViewControllerAnimated(true)
            }, errorHandler: nil)
        } else {
            rightBarButton.enabled = true
            AlertCreator.singleActionAlert("Error", message: "Please fill all text fields.", actionTitle: "OK", actionHandler: nil)
        }
    }
    
    @IBAction func barButtonPressed(sender: UIBarButtonItem) {
        sender.enabled = false
        guard let viewPurpose = viewPurpose else {
            return
        }
        
        switch viewPurpose {
        case .Create:
            createRoom()
