Null date reference when passing json to MVC Controller

Posted by Jake on Stack Overflow See other posts from Stack Overflow or by Jake
Published on 2010-03-29T13:41:04Z Indexed on 2010/03/29 13:43 UTC
Read the original article Hit count: 451

I am building an event system that posts data to a google calendar. I am using jquery 1.4.2, fullcalendar 1.4.5, and asp.net MVC 2. I am using a jquery ui modal dialog for the entry system. Jquery ui datepicker for the from and to fields. Select boxes for the time fields. I have tried both string and DateTime formats in the GCalEvent Class for startDate, startTime, endDate and endTime.

I am receiving a null reference with the dates passed to the controllers Action method.

var gcalevent = {
                        'eventID': $('#eventID').val(),
                        'eventURL': $('#eventURL').val(),
                        'date': {
                            'startDate': $("#from").val(),
                            'startTime': $('#eventStartHour option:selected').val() + ":" + $('#eventStartMin option:selected').val() + $('#eventStartAMPM option:selected').val(),
                            'endDate': $('#to').val(),
                            'endTime': $('#eventEndHour option:selected').val() + ":" + $('#eventEndMin option:selected').val() + $('#eventEndAMPM option:selected').val()
                        },
                        'allDay': $('#chkAllDay').attr('checked'),
                        'where': $('#eventWhere').val(),
                        'eventTitle': $('#eventTitle').val(),
                        'eventDescription': $('#eventDescription').val()
                    };
$.post("/home/AddRepeatingEvent", gcalevent, addEventCallback);

public void AddNonRepeatingEvent(Models.GCalEvent gcalevent)
    {
        IGCalRepository _gcalrepo;
        GCalRepository gcalrepo = new GCalRepository();
        _gcalrepo = gcalrepo;
        //_gcalrepo.AddEvent(gcalevent);
        GetGoogleEventURL(gcalevent.eventID.ToString());
    }

public enum Days
{
    Sun,
    Mon,
    Tue,
    Wed,
    Thur,
    Fri,
    Sat
}
public enum DefaultCalendarView
{
    Month,
    Day,
    Week
}
public enum OrderType
{
    First,
    Second,
    Third,
    Fourth,
    Last
}
public abstract class RepeatBaseType
{      
}
public class GCalEvent
{
    public string title { get; set; }
    public string description { get; set; }
    public string where { get; set; }
    public bool repeated { get; set; }
    public bool allDay { get; set; }
    public DefaultCalendarView defaultCalendarView { get; set; }
    public GCalEventDate date { get; set; }
    public RepeatBaseType repeatType { get; set; }
    public string eventID { get; set; }
    public string eventURL { get; set; }

}
public class GCalEventDate
{
    public string startDate { get; set; }
    public string startTime { get; set; }
    public string endDate {get;set;}
    public string endTime  {get;set;}        
}
internal class Duration
{
    int Days { get; set; }
    int Hours { get; set; }
    int Minutes { get; set; }
}
public class RepeatedDaily: RepeatBaseType
{
    public int Days { get; set; }
}
public class RepeatedWeekly : RepeatBaseType
{
    public int Weeks { get; set; }        
    public Days[] days { get; set; }
}
public class RepeatedMonthly : RepeatBaseType
{
    public int Months { get; set; }
    public RepeatedMonthlyType repeatedMonthlyType { get; set; }       
}
public class RepeatedYearly : RepeatBaseType
{
  public int Years {get;set;}
}
public abstract class RepeatedMonthlyType
    {                    
    }
public class RepeatedMonthlyDayOfWeek : RepeatedMonthlyType
{
    public Days[] DayOfWeek { get; set; }
    public OrderType orderType { get; set; }
}
public class RepeatedMonthlyDayOfMonth : RepeatedMonthlyType
{
    public DateTime DayOfMonth { get; set; }
}

This is the first time i am attempting to use abastract classes. Thank you for your help.

© Stack Overflow or respective owner

Related posts about fullcalendar

Related posts about asp.net-mvc