public override void ViewDidLoad ()
		{
			base.ViewDidLoad ();
			newDate = new ProposedDate ();
			// Perform any additional setup after loading the view, typically from a nib.
			modalPicker = new ModalPickerViewController(ModalPickerType.Date, "2 hrs to 10 days", this) {
				HeaderBackgroundColor = UIColor.Red,
				HeaderTextColor = UIColor.White,
				TransitioningDelegate = new ModalPickerTransitionDelegate(),
				ModalPresentationStyle = UIModalPresentationStyle.Custom
			};

			modalPicker.DatePicker.Mode = UIDatePickerMode.DateAndTime;
			DateTime minDate = DateTime.UtcNow.AddHours (2);
			DateTime maxDate = DateTime.UtcNow.AddDays (10);

			modalPicker.DatePicker.MinimumDate = minDate.DateTimeToNSDate();
			modalPicker.DatePicker.MaximumDate = maxDate.DateTimeToNSDate();
			modalPicker.DatePicker.MinuteInterval = 15;
			modalPicker.OnModalPickerDismissed += HandleDatePicked;


			DateStartBtn.TouchUpInside += (object sender, EventArgs e) => 
			{
				ShowDateController();


			};

			CancelDateBtn.TouchUpInside += (object sender, EventArgs e) => {
				DismissViewController(true, null);
			};

			CreateDateBtn.TouchUpInside += (object sender, EventArgs e) => {
				LettuceServer.Instance.CreateDate(newDate, (theDate) =>
					{
						newDate = theDate;
						InvokeOnMainThread(() => {
						DismissViewController(true, null);
						if (DateCreated != null)
							DateCreated(theDate);
						});
					});

			};

			AddActivityBtn.TouchUpInside += (sender, e) => {
				if ((newDate.activities == null) || (newDate.activities.Count == 0))
					AddNewActivityToDate ();
				else
					RemoveAllActivitiesFromDate ();
			};
				

			ActivityTableView.RegisterNibForCellReuse (UINib.FromName (ActivitySummaryCell.Key, NSBundle.MainBundle), ActivitySummaryCell.Key);
			ActivityTableView.Source = new DateActivityDataSource (this.newDate);
			ActivityTableView.RowHeight = 164;

			keyWatcher = NSNotificationCenter.DefaultCenter.AddObserver (UITextView.TextDidChangeNotification, (notification) => {
				newDate.description = DescriptionText.Text;
				newDate.title = HeadlineText.Text;
				UpdateCreateButton();
			});
		}
 public void ConformToRecord(BaseDate theDate)
 {
     DateIcon.Hidden = false;
     linkedDate = theDate;
     DateTitle.Text = theDate.title;
 }
 public void ConformToEmpty()
 {
     linkedDate = null;
     DateIcon.Hidden = true;
     DateTitle.Text = "NoBookedDatesCell_String".Localize();
 }
 public DateActivityDataSource(BaseDate dateSource)
 {
     currentDate = dateSource;
 }
		public void CreateDate(BaseDate theDate, BaseDate_callback callback)
		{
			string fullURL = "date";

			RestRequest request = new RestRequest(fullURL, Method.POST);
			request.AddParameter("date", theDate.ToJson());

			apiClient.ExecuteAsync<BaseDate>(request, (response) =>
				{
					BaseDate newDate = response.Data;
					if (newDate != null)
					{
						callback(newDate);
					}
					else
						callback(null);
				});
		}
        // celltypes
        // 1 - booked date
        // 2 - date with applicant
        // 3 - open date
        // 4 - proposed date
        // 5 - date in the past
        public void ConformToRecord(BaseDate theDate, int cellType)
        {
            linkedDate = theDate;
            AgeLabel.Text = theDate.proposerAge.ToString();
            CommIcon.Image = UIImage.FromBundle("mailbadge");

            if (cellType == 1)
            {
                CommIcon.Hidden = false;

                if (theDate.messageCount > 0)
                {
                    CountView.Hidden = false;
                    CountLabel.Hidden = false;
                    CountLabel.Text = theDate.messageCount.ToString();
                }
                else {
                    CountLabel.Hidden = true;
                    CountView.Hidden = true;
                }
            }
            else {
                CountView.Hidden = true;
                CountLabel.Hidden = true;
                CommIcon.Hidden = true;
            }

            DateTimeLabel.Text = theDate.shortTimeStr;

            string paymentStr = "";

            switch (theDate.paymentStyle)
            {
                case 0:
                    paymentStr = "DatePayment_Summary_0_str".Localize();
                    break;
                case 1:
                    paymentStr = "DatePayment_Summary_1_str".Localize();
                    break;
                case 2:
                    paymentStr = "DatePayment_Summary_2_str".Localize();
                    break;
            }
            DateTreatLabel.Text = paymentStr;

            string dateTypeStr = "";
            Activity activity = theDate.activities[0];

            switch (activity.type)
            {
                case 1:
                    dateTypeStr = "DateType_1_str".Localize();
                    break;
                case 2:
                    dateTypeStr = "DateType_2_str".Localize();
                    break;
                case 3:
                    dateTypeStr = "DateType_3_str".Localize();
                    break;
                case 4:
                    dateTypeStr = "DateType_4_str".Localize();
                    break;
            }
            DateTypeLabel.Text = dateTypeStr;

            NameLabel.Text = theDate.proposerName;

            NoticeImg.Image = UIImage.FromBundle("newbadge");
            PersonImage.SetImage(new NSUrl(theDate.selfie));

            string relativeDateStr = "";
            if (theDate.starttime.Date == DateTime.Today)
                relativeDateStr = "Date_Today_Str".Localize();
            else if (theDate.starttime.Date == DateTime.Today.AddDays(1))
                relativeDateStr = "Date_Tomorrow_Str".Localize();
            else
                relativeDateStr = theDate.starttime.DayOfWeek.ToString();   // TO DO - localize.

            RelativeDayLabel.Text = relativeDateStr;

            LettuceServer.Instance.LoadVenue(activity.venueid).ContinueWith((theTask) =>
            {
                Venue theVenue = theTask.Result;
                InvokeOnMainThread(() =>
                {

                    VenueAddressLabel.Text = theVenue.address;
                    VenueNameLabel.Text = theVenue.title;
                    VenueImage.SetImage(new NSUrl(theVenue.image));
                });
            });
        }