/**
  * @Route("/properties/design", name="properties_design")
  */
 public function designAction(Request $request)
 {
     $mls_id = $request->get('mls_id');
     $property_id = $request->get('property_id');
     $user = $this->getUser();
     //Design a property from MLS
     if ($mls_id) {
         $mls_property = $this->getBusiness()->getMlsProperty($mls_id);
         $new_property = new Property($user);
         $property = $this->getBusiness()->propertyApiMapper($mls_property, $new_property);
         $property_id = $property->getId();
         return $this->redirectToRoute('properties_design', array('property_id' => $property_id));
     } else {
         if ($property_id) {
             $property = $this->getDoctrine()->getRepository('DashboardBundle:Property')->find($property_id);
         } else {
             $property = new Property($user);
             $property->setName('New Property');
             $this->getBusiness()->saveProperty($property);
             $property_id = $property->getId();
             return $this->redirectToRoute('properties_design', array('property_id' => $property_id));
         }
     }
     $property_form = $this->createForm(PropertyType::class, $property);
     $property_photo_form = $this->createForm(PropertyPhotoType::class, new PropertyPhoto($property));
     return $this->render('DashboardBundle:Properties:design.html.twig', array('mls_id' => $mls_id, 'property_id' => $property_id, 'property' => $property, 'property_form' => $property_form->createView(), 'property_photo_form' => $property_photo_form->createView()));
 }
 public function propertyApiMapper($data, Property $property)
 {
     $uploader = $this->container->get('speicher210_cloudinary.uploader');
     $property->setName($data['property']['subdivision']);
     $property->setDescription($data['property']['lotDescription']);
     $property->setFeatures('Style: ' . $data['property']['style'] . ' - ' . 'View: ' . $data['property']['view'] . ' - ' . 'Construction: ' . $data['property']['construction'] . ' - ' . 'Accessibility: ' . $data['property']['accessibility'] . ' - ' . 'Heating: ' . $data['property']['heating'] . ' - ' . 'Laundry Features: ' . $data['property']['laundryFeatures'] . ' - ' . 'Interior Features: ' . $data['property']['interiorFeatures'] . ' - ' . 'Exterior Features: ' . $data['property']['exteriorFeatures']);
     //$property->setType($data['property']['type']);
     $property->setLeaseTerm($data['leaseTerm']);
     $property->setBedrooms($data['property']['bedrooms']);
     $property->setBathrooms($data['property']['bathsFull'] + $data['property']['bathsHalf']);
     $property->setUnitSize($data['property']['lotSize']);
     $property->setYearBuilt($data['property']['yearBuilt']);
     $property->setMlsId($data['mlsId']);
     $property->setAddress($data['address']['full']);
     $property->setUnit($data['address']['unit']);
     $property->setCity($data['address']['city']);
     $property->setState($data['address']['state']);
     $property->setCountry($data['address']['country']);
     $property->setPostalCode($data['address']['postalCode']);
     $property->setLat($data['geo']['lat']);
     $property->setLng($data['geo']['lng']);
     $property->setMapCenterLat($data['geo']['lat']);
     $property->setMapCenterLng($data['geo']['lng']);
     if (!empty($data['photos'])) {
         foreach ($data['photos'] as $photo) {
             $result = $uploader->upload($photo, array('folder' => 'properties'));
             $propertyPhoto = new PropertyPhoto($property);
             $propertyPhoto->setPhotoId($result['public_id']);
             $propertyPhoto->setPhotoUrl($result['url']);
             $property->addPhoto($propertyPhoto);
         }
     }
     $this->saveProperty($property);
     return $property;
 }