public static void Save(OccurrencesAdminDetailView parent, SubEntity occurrenceDates, int occurrenceId)
        {
            try
            {
                occurrenceDates.ErrorMessage = string.Empty;

                //Existing Records Added
                foreach (var record in occurrenceDates.Records.Where(r => r.Action == RecordActions.New))
                {
                    var startDate = parent.GetFieldValue(record.Fields, _day);
                    var startTime = parent.GetFieldValue(record.Fields, _startTime);
                    var endTime = parent.GetFieldValue(record.Fields, _endTime);

                    var d = GetDateTime(startDate, "Date");
                    d = GetDateTime(d.ToShortDateString(), "Date");

                    var s = GetDateTime(startTime, "Start Time").TimeOfDay.TotalDays;
                    var e = GetDateTime(endTime, "End Time").TimeOfDay.TotalDays;

                    var requestStartDate = d.AddDays(s);
                    var requestEndDate = d.AddDays(e);

                    var request = new AddOccurrenceDateRequest
                    {
                        StartDate = requestStartDate,
                        EndDate = requestEndDate,
                        EventOccurrenceId = occurrenceId
                    };
                    parent.ProcessRequest<AddOccurrenceDateResponse>(request);
                }

                //Records Deleted
                foreach (var record in occurrenceDates.Records.Where(r => r.Action == RecordActions.Deleted))
                {
                    var request = new DeleteOccurrenceDateRequest
                    {
                        EventOccurrenceDateId = record.Id
                    };
                    parent.ProcessRequest<DeleteOccurrenceDateResponse>(request);
                }
            }
            catch (Exception ex)
            {
                occurrenceDates.ErrorMessage = ex.Message;
                throw;
            }
        }
 private static IEnumerable<EventOccurrenceDateDto> GetEventOccurrenceDates(OccurrencesAdminDetailView parent, int occurrenceId)
 {
     var request = new ReadEventOccurrenceRequest { Id = occurrenceId };
     return parent.ProcessRequest<ReadEventOccurrenceResponse>(request).EventOccurrence.EventOccurrenceDates;
 }