Dynamic class structure holding events for each day of the month

data structure for recurring events
fullcalendar
add event dynamically in fullcalendar example
recurring events database design
database design for calendar events
recurring event design pattern
recurring task database design
calculating recurring events

I have to represent JSON as class structures so I can use it to return those class in asp.net core endpoints. I need to return object holding each day of the current month and for every day holds array of events.

Here is the JSON, where numbers are day of the month.

[
  {
    "1":[
      {
        "Title":"Meeting",
        "DateTime":"12:40"
      },
      {
        "Title":"Launch",
        "DateTime":"13:30"
      }
    ],
    "2":[
      {
        "Title":"Test",
        "DateTime":"9:30"
      }
    ]
  }
]

Here is the code:

public class 1
{
    public string Title { get; set; }
    public string DateTime { get; set; }
}

public class 2
{
    public string Title { get; set; }
    public string DateTime { get; set; }
}

public class MonthEventsResponseModel
{
    public IList<1> 1 { get; set; }
    public IList<2> 2 { get; set; }
    // and so on to 31
}

So if there is a better solution for achieving this, I'm glad to know.

One approach would be,

1) Create enum for all month in year,

public enum Month
{
    NotSet = 0,
    January = 1,
    February = 2,
    March = 3,
    April = 4,
    May = 5,
    June = 6,
    July = 7,
    August = 8,
    September = 9,
    October = 10,
    November = 11,
    December = 12
}

2) Create one custom method that can take a month from above enum for a particular year, and it calculates a number of days in a given month and for each of day you can fill your event data

public static MonthEventsResponseModel GetEventData(int year, Month month)
{
    var days = DateTime.DaysInMonth(year, (int)month);

    MonthEventsResponseModel model = new MonthEventsResponseModel();
    model.Events = Enumerable.Range(1, days)
        .Select(day => new
        {
            Day = day,
            Event = new List<Event>()  //<= Instead of new list, Fill Event data with respect to particular day from List or Database Call or API call
        })
        .ToDictionary(x => x.Day, y => y.Event);

    return model;
}

3) Then call above method like,

MonthEventsResponseModel model = GetEventData(2018, Month.December);

4) Finally convert your model to json,

string json = JsonConvert.SerializeObject(model);

5) And class models are,

public class Event
{
    public string Title { get; set; }
    public string DateTime { get; set; }
}

public class MonthEventsResponseModel
{
    public Dictionary<int, List<Event>> Events { get; set; }
}

Calendar Recurring/Repeating Events, Event A repeats every month on the 3rd of the month starting on March 3, 2011 I'd recommend combining this with the above system for the most flexibility. By looping over each day in the calendar you can get repeat events using this to be stored as type 'date' and repeat_interval now hold days rather than seconds. On the Term Table page, select the Use Dynamic Class Dates check box to select the Dynamic Class Dates feature by default for each session created within a term. See Defining Terms . On the Session Table page, select the Use Dynamic Class Dates check box to enable the Dynamic Class Dates feature for all classes that you schedule within a session.

Create a class that will describe an event:

public class Event
{
    public string Title { get; set; }
    public string DateTime { get; set; }
}

And modify your MonthEventsResponseModel to this:

public class MonthEventsResponseModel
{
    public Dictionary<int, List<Event>> Events { get; set; }
}

Now you can deserialize your json with DeserializeObject method and some linq:

var json = "[\r\n  {\r\n    \"1\":[\r\n      {\r\n        \"Title\":\"Meeting\",\r\n        \"DateTime\":\"12:40\"\r\n      },\r\n      {\r\n        \"Title\":\"Launch\",\r\n        \"DateTime\":\"13:30\"\r\n      }\r\n    ],\r\n    \"2\":[\r\n      {\r\n        \"Title\":\"Test\",\r\n        \"DateTime\":\"9:30\"\r\n      }\r\n    ]\r\n  }\r\n]";

var result = JsonConvert.DeserializeObject<Dictionary<string, Event[]>[]>(json)
    .Select(x => new MonthEventsResponseModel
    {
        Events = x.ToDictionary(k => int.Parse(k.Key), v => v.Value.ToList())
    }).ToArray();

Event Object, A JavaScript object that FullCalendar uses to store information about a calendar event. API such as getEventById and provides methods for dynamic manipulation. Determines if the event is shown in the “all-day” section of relevant views. A plain object holding miscellaneous other properties specified during parsing. Note: This example assumes the start date will be provided as the first of the month. See below for a formula that will dynamically return the first day of the current month. With the layout of grid as shown, the main problem is calculate the date in the first cell in the calendar (B6). This is done with this formula:

I'd go ahead and make Event, Day, Month models, each responsible for serializing themselves -

Event

    public class Event
    {
        public string Title { get; set; }
        public string DateTime { get; set; }

        public string MakeJson()
        {

            StringBuilder stringBuilder = new StringBuilder();

            stringBuilder
                .Append("  {").AppendLine()
                .Append("    \"Title\":\"" + Meeting + "\",").AppendLine()
                .Append("    \"DateTime\":\"" + DateTime + "\"").AppendLine()
                .Append("  },").AppendLine();

            return stringBuilder.ToString();
        }
    }

Day

    public class Day
    {
        public string DayNo { get; set; }
        public List<Event> Events { get; set; }

        public string MakeJson()
        {
            StringBuilder stringBuilder = new StringBuilder();

            stringBuilder.Append("\"" + DayNo + "\":[").AppendLine();    

            foreach (Event ev in Events)
            {
                stringBuilder.Append(ev.MakeJson());
            }

            stringBuilder.AppendLine().Append("],").AppendLine();

            return stringBuilder.ToString();
        }
    }

Month

    public class Month{

        public List<Day> Days { get; set; }

        public string MakeJson()
        {
            StringBuilder stringBuilder = new StringBuilder();

            stringBuilder.Append("[")
                .AppendLine().Append(" {")
                .AppendLine();

            foreach (Day day in Days)
            {
                stringBuilder.Append(day.MakeJson());
            }

            stringBuilder.Append(" }")
                .AppendLine().Append("]")
                .AppendLine();


        }
    }

Once you populate the models just call MakeJson() on the month and you're good to go.

Calendar Class in Java with examples, As it is an Abstract class, so we cannot use a constructor to create an instance. Instead, we System.out.println( "Current Calendar's Day: " +� In a weekly Excel schedule template, each day is broken up into morning, afternoon, and evening, and you can adjust how much space you would like for each block of the day. Common uses: College class schedule: Get a high-level view of all your classes for the week with a class schedule. You can quickly fill in their course information, like

Appointments in JavaScript Schedule control, To change normal appointment into all-day event, set isAllDay field to true. Week, WorkWeek, Month, Agenda } from '@syncfusion/ej2-schedule'; let data: object To dynamically edit a particular occurrence from an event series and display it on In mobile mode, you can drag and drop the events by tap holding an event� 3. One player from each team can look at the structure for 10 seconds. After this, the player has to return to his/her team and instruct them on how to build the structure for 25 seconds. 4. Each team takes 1 minute to build the structure as per the instructions.

Free Excel Schedule Templates for Schedule Makers, All you need to make a weekly, daily, or monthly schedule in Excel. From organizing your to-do list to planning an event, a schedule will keep you on track weekly, or monthly template, you then need to choose a layout, duration type ( do you In a weekly Excel schedule template, each day is broken up into morning,� See how events are are parsed from a plain object for further details. startStr: An ISO8601 string representation of the start date. If the event is all-day, there will not be a time part. endStr: An ISO8601 string representation of the end date. If the event is all-day, there will not be a time part. title: String. The text that will appear on

The dynamic chain event graph, a flu vaccine. Keywords and phrases: Chain Event Graphs, Markov processes, proba- In this paper we propose a novel class of graphical models called Dynamic Chain. Event Graph Furthermore structural zero probabilities in the conditional probability tables conditional holding times to each edge within the graph. Deciding what type of event you should hold will depend on your goals, as well as the size and demographic of your target audience. However, here are 10 tried and trusted ideas for community events that should help get everyone together. For further ideas, tips and tricks for community events, join the discussion over industry forum EventTribe. 1.

Comments
  • Despite the fact that List<1> 1 won´t compile you should use a List<List<Whatever>>, as not every month has 31 days. Altrnativly also a jagged array However I´m not sure if that´s what you consider "better solution".
  • Call the class Day and have a property DayOfMonth which is 1 to (n) days.
  • Thanks you man, actually I don't need to fill all days if there is no events for that day, but your solution was most helpfup so I will accept your answer for best. :)
  • I don't ned to Deserialize Objects, I need to Serialize them from class to JSON.
  • @IliyanIvanov Please show your actual data source from which you taking events.
  • I'm taking them from Event entity class with EF Core 2.2. dbContext.Event (that returns IQueryable<Event>)
  • @IliyanIvanov you need to edit your question and add source code of that Event class
  • I solve my problem, thanks for trying to help me. The class structure I have needed was Dictionary<int, IEnumerable<Even>>