将json传递给MVC Controller时的空日期引用

时间:2010-03-29 13:41:04

标签: jquery asp.net-mvc json jquery-ui fullcalendar

我正在构建一个将数据发布到Google日历的事件系统。我正在使用jquery 1.4.2,fullcalendar 1.4.5和asp.net MVC 2.我正在使用jquery ui模式对话框进入系统。 Jquery ui datepicker用于from和to字段。选择时间字段的框。我已经在GCalEvent类中为startDate,startTime,endDate和endTime尝试了字符串和DateTime格式。

我收到一个空引用,其中包含传递给控制器​​Action方法的日期。

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; }
}

这是我第一次尝试使用abastract课程。 谢谢你的帮助。

1 个答案:

答案 0 :(得分:0)

我认为您的答案在本文中: http://weblogs.asp.net/gunnarpeipman/archive/2010/02/03/using-fullcalendar-jquery-component-with-asp-net-mvc.aspx?CommentPosted=true#commentmessage

我的猜测是你必须使用Unix时间戳作为时间和日期的再现......