protected static FR_Guid Execute(DbConnection Connection, DbTransaction Transaction, P_L5DO_SDaSA_1634 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null) { #region UserCode var returnValue = new FR_Guid(); foreach (var item in Parameter.AvailabilityDate) { #region Delete if (item.IsDeleted) { ORM_CMN_BPT_BusinessParticipant_Availability.Query.SoftDelete(Connection, Transaction, new ORM_CMN_BPT_BusinessParticipant_Availability.Query() { Tenant_RefID = securityTicket.TenantID, IsDeleted = false, CMN_BPT_BusinessParticipant_AvailabilityID = item.OfficeAvailabilityID }); } #endregion else { var officeAvailabilityQuery = new ORM_CMN_BPT_BusinessParticipant_Availability.Query(); officeAvailabilityQuery.Tenant_RefID = securityTicket.TenantID; officeAvailabilityQuery.IsDeleted = false; officeAvailabilityQuery.CMN_BPT_BusinessParticipant_AvailabilityID = item.OfficeAvailabilityID; var bpAvailability = ORM_CMN_BPT_BusinessParticipant_Availability.Query.Search(Connection, Transaction, officeAvailabilityQuery).SingleOrDefault(); #region Save if (bpAvailability == null) { bpAvailability = new ORM_CMN_BPT_BusinessParticipant_Availability(); bpAvailability.CMN_BPT_BusinessParticipant_AvailabilityID = item.OfficeAvailabilityID; bpAvailability.BusinessParticipant_RefID = Parameter.CMN_BPT_BusinessParticipantID; bpAvailability.CMN_CAL_AVA_Availability_RefID = Guid.NewGuid(); bpAvailability.Tenant_RefID = securityTicket.TenantID; bpAvailability.Creation_Timestamp = DateTime.Now; bpAvailability.Save(Connection, Transaction); var availability = new ORM_CMN_CAL_AVA_Availability(); availability.CMN_CAL_AVA_AvailabilityID = bpAvailability.CMN_CAL_AVA_Availability_RefID; availability.Tenant_RefID = securityTicket.TenantID; availability.Creation_Timestamp = DateTime.Now; var availabilityTypeQuery = new ORM_CMN_CAL_AVA_Availability_Type.Query(); availabilityTypeQuery.IsDeleted = false; availabilityTypeQuery.Tenant_RefID = securityTicket.TenantID; availabilityTypeQuery.GlobalPropertyMatchingID = item.Type; var availabilityType = ORM_CMN_CAL_AVA_Availability_Type.Query.Search(Connection, Transaction, availabilityTypeQuery).First(); availability.Office_RefID = item.OfficeID; availability.AvailabilityType_RefID = availabilityType.CMN_CAL_AVA_Availability_TypeID; availability.IsAvailabilityExclusionItem = item.IsException; availability.Save(Connection, Transaction); Guid EventId = Guid.NewGuid(); var date = new ORM_CMN_CAL_AVA_Date(); date.CMN_CAL_AVA_DateID = Guid.NewGuid(); date.Availability_RefID = availability.CMN_CAL_AVA_AvailabilityID; date.CMN_CAL_Event_RefID = EventId; date.DateName = item.AvailabilityDate_Name; date.DateComment = item.Reason; date.Tenant_RefID = securityTicket.TenantID; date.Creation_Timestamp = DateTime.Now; date.Save(Connection, Transaction); var events = new ORM_CMN_CAL_Event(); events.CMN_CAL_EventID = EventId; events.IsRepetitive = item.IsRepetitive; events.StartTime = item.AvailabilityDate_From; events.EndTime = item.AvailabilityDate_To; events.Tenant_RefID = securityTicket.TenantID; events.Creation_Timestamp = DateTime.Now; events.IsWholeDayEvent = item.IsWholeDay; if (item.IsRepetitive) { events.Repetition_RefID = Guid.NewGuid(); var repetitions = new ORM_CMN_CAL_Repetition(); repetitions.CMN_CAL_RepetitionID = events.Repetition_RefID; repetitions.IsMonthly = item.IsMontly; repetitions.IsWeekly = item.IsWeekly; repetitions.IsDaily = item.IsDaily; repetitions.IsYearly = item.IsYearly; repetitions.Tenant_RefID = securityTicket.TenantID; repetitions.Creation_Timestamp = DateTime.Now; repetitions.Save(Connection, Transaction); if (item.IsWeekly) { var repetitionWeekly = new ORM_CMN_CAL_RepetitionPatterns_Weekly(); repetitionWeekly.CMN_CAL_RepetitionPattern_WeeklyID = Guid.NewGuid(); repetitionWeekly.Repetition_RefID = repetitions.CMN_CAL_RepetitionID; repetitionWeekly.Tenant_RefID = securityTicket.TenantID; repetitionWeekly.Creation_Timestamp = DateTime.Now; repetitionWeekly.HasRepeatingOn_Fridays = item.HasRepeatingOn_Fridays; repetitionWeekly.HasRepeatingOn_Mondays = item.HasRepeatingOn_Mondays; repetitionWeekly.HasRepeatingOn_Saturdays = item.HasRepeatingOn_Saturdays; repetitionWeekly.HasRepeatingOn_Sundays = item.HasRepeatingOn_Sundays; repetitionWeekly.HasRepeatingOn_Thursdays = item.HasRepeatingOn_Thursdays; repetitionWeekly.HasRepeatingOn_Tuesdays = item.HasRepeatingOn_Tuesdays; repetitionWeekly.HasRepeatingOn_Wednesdays = item.HasRepeatingOn_Wednesdays; repetitionWeekly.Save(Connection, Transaction); } if (item.IsMontly) { var repetitionMontly = new ORM_CMN_CAL_RepetitionPatterns_Monthly(); repetitionMontly.CMN_CAL_RepetitionPattern_MonthlyID = Guid.NewGuid(); repetitionMontly.Repetition_RefID = repetitions.CMN_CAL_RepetitionID; repetitionMontly.Tenant_RefID = securityTicket.TenantID; repetitionMontly.Creation_Timestamp = DateTime.Now; repetitionMontly.Save(Connection, Transaction); } if (item.IsDaily) { var repetitionDaily = new ORM_CMN_CAL_RepetitionPatterns_Daily(); repetitionDaily.CMN_CAL_RepetitionPattern_DailyID = Guid.NewGuid(); repetitionDaily.Repetition_RefID = repetitions.CMN_CAL_RepetitionID; repetitionDaily.Tenant_RefID = securityTicket.TenantID; repetitionDaily.Creation_Timestamp = DateTime.Now; repetitionDaily.Save(Connection, Transaction); } if (item.IsYearly) { var repetitionYearly = new ORM_CMN_CAL_RepetitionPatterns_Yearly(); repetitionYearly.CMN_CAL_RepetitionPattern_YearlyID = Guid.NewGuid(); repetitionYearly.Repetition_RefID = repetitions.CMN_CAL_RepetitionID; repetitionYearly.Tenant_RefID = securityTicket.TenantID; repetitionYearly.Creation_Timestamp = DateTime.Now; repetitionYearly.Save(Connection, Transaction); } } events.Save(Connection, Transaction); } #endregion #region Edit else { bpAvailability.Save(Connection, Transaction); var eventsQuery = new ORM_CMN_CAL_Event.Query(); eventsQuery.IsDeleted = false; eventsQuery.Tenant_RefID = securityTicket.TenantID; var availability = ORM_CMN_CAL_AVA_Availability.Query.Search(Connection, Transaction, new ORM_CMN_CAL_AVA_Availability.Query() { Tenant_RefID = securityTicket.TenantID, IsDeleted = false, CMN_CAL_AVA_AvailabilityID = bpAvailability.CMN_CAL_AVA_Availability_RefID }).Single(); availability.Office_RefID = item.OfficeID; availability.Save(Connection, Transaction); var dateQuery = new ORM_CMN_CAL_AVA_Date.Query(); dateQuery.IsDeleted = false; dateQuery.Tenant_RefID = securityTicket.TenantID; dateQuery.Availability_RefID = bpAvailability.CMN_CAL_AVA_Availability_RefID; var date = ORM_CMN_CAL_AVA_Date.Query.Search(Connection, Transaction, dateQuery).Single(); date.DateName = item.AvailabilityDate_Name; date.DateComment = item.Reason; date.Save(Connection, Transaction); eventsQuery.CMN_CAL_EventID = date.CMN_CAL_Event_RefID; var Events = ORM_CMN_CAL_Event.Query.Search(Connection, Transaction, eventsQuery).Single(); Events.IsRepetitive = item.IsRepetitive; Events.IsWholeDayEvent = item.IsWholeDay; Events.StartTime = item.AvailabilityDate_From; Events.EndTime = item.AvailabilityDate_To; #region delete old repetation if exists var repetitionsQuery = new ORM_CMN_CAL_Repetition.Query(); repetitionsQuery.IsDeleted = false; repetitionsQuery.Tenant_RefID = securityTicket.TenantID; repetitionsQuery.CMN_CAL_RepetitionID = Events.Repetition_RefID; var repetitions = ORM_CMN_CAL_Repetition.Query.Search(Connection, Transaction, repetitionsQuery).SingleOrDefault(); if (repetitions != null) { repetitions.IsDeleted = true; repetitions.Save(Connection, Transaction); if (repetitions.IsWeekly) { ORM_CMN_CAL_RepetitionPatterns_Weekly.Query.SoftDelete(Connection, Transaction, new ORM_CMN_CAL_RepetitionPatterns_Weekly.Query() { IsDeleted = false, Tenant_RefID = securityTicket.TenantID, Repetition_RefID = repetitions.CMN_CAL_RepetitionID, }); } if (repetitions.IsMonthly) { ORM_CMN_CAL_RepetitionPatterns_Monthly.Query.SoftDelete(Connection, Transaction, new ORM_CMN_CAL_RepetitionPatterns_Monthly.Query() { Repetition_RefID = repetitions.CMN_CAL_RepetitionID, Tenant_RefID = securityTicket.TenantID, IsDeleted = false }); } if (repetitions.IsDaily) { ORM_CMN_CAL_RepetitionPatterns_Daily.Query.SoftDelete(Connection, Transaction, new ORM_CMN_CAL_RepetitionPatterns_Daily.Query() { Repetition_RefID = repetitions.CMN_CAL_RepetitionID, IsDeleted = false, Tenant_RefID = securityTicket.TenantID }); } if (repetitions.IsYearly) { ORM_CMN_CAL_RepetitionPatterns_Yearly.Query.SoftDelete(Connection, Transaction, new ORM_CMN_CAL_RepetitionPatterns_Yearly.Query() { Tenant_RefID = securityTicket.TenantID, IsDeleted = false, Repetition_RefID = repetitions.CMN_CAL_RepetitionID }); } } #endregion if (item.IsRepetitive) { Events.Repetition_RefID = Guid.NewGuid(); repetitions = new ORM_CMN_CAL_Repetition(); repetitions.CMN_CAL_RepetitionID = Events.Repetition_RefID; repetitions.IsMonthly = item.IsMontly; repetitions.IsWeekly = item.IsWeekly; repetitions.IsDaily = item.IsDaily; repetitions.IsYearly = item.IsYearly; repetitions.Tenant_RefID = securityTicket.TenantID; repetitions.Creation_Timestamp = DateTime.Now; repetitions.Save(Connection, Transaction); if (item.IsWeekly) { var repetitionWeekly = new ORM_CMN_CAL_RepetitionPatterns_Weekly(); repetitionWeekly.CMN_CAL_RepetitionPattern_WeeklyID = Guid.NewGuid(); repetitionWeekly.Repetition_RefID = repetitions.CMN_CAL_RepetitionID; repetitionWeekly.Tenant_RefID = securityTicket.TenantID; repetitionWeekly.Creation_Timestamp = DateTime.Now; repetitionWeekly.HasRepeatingOn_Fridays = item.HasRepeatingOn_Fridays; repetitionWeekly.HasRepeatingOn_Mondays = item.HasRepeatingOn_Mondays; repetitionWeekly.HasRepeatingOn_Saturdays = item.HasRepeatingOn_Saturdays; repetitionWeekly.HasRepeatingOn_Sundays = item.HasRepeatingOn_Sundays; repetitionWeekly.HasRepeatingOn_Thursdays = item.HasRepeatingOn_Thursdays; repetitionWeekly.HasRepeatingOn_Tuesdays = item.HasRepeatingOn_Tuesdays; repetitionWeekly.HasRepeatingOn_Wednesdays = item.HasRepeatingOn_Wednesdays; repetitionWeekly.Save(Connection, Transaction); } if (item.IsMontly) { var repetitionMontly = new ORM_CMN_CAL_RepetitionPatterns_Monthly(); repetitionMontly.CMN_CAL_RepetitionPattern_MonthlyID = Guid.NewGuid(); repetitionMontly.Repetition_RefID = repetitions.CMN_CAL_RepetitionID; repetitionMontly.Tenant_RefID = securityTicket.TenantID; repetitionMontly.Creation_Timestamp = DateTime.Now; repetitionMontly.Save(Connection, Transaction); } if (item.IsDaily) { var repetitionDaily = new ORM_CMN_CAL_RepetitionPatterns_Daily(); repetitionDaily.CMN_CAL_RepetitionPattern_DailyID = Guid.NewGuid(); repetitionDaily.Repetition_RefID = repetitions.CMN_CAL_RepetitionID; repetitionDaily.Tenant_RefID = securityTicket.TenantID; repetitionDaily.Creation_Timestamp = DateTime.Now; repetitionDaily.Save(Connection, Transaction); } if (item.IsYearly) { var repetitionYearly = new ORM_CMN_CAL_RepetitionPatterns_Yearly(); repetitionYearly.CMN_CAL_RepetitionPattern_YearlyID = Guid.NewGuid(); repetitionYearly.Repetition_RefID = repetitions.CMN_CAL_RepetitionID; repetitionYearly.Tenant_RefID = securityTicket.TenantID; repetitionYearly.Creation_Timestamp = DateTime.Now; repetitionYearly.Save(Connection, Transaction); } } Events.Save(Connection, Transaction); } #endregion } } var emp = ORM_CMN_BPT_EMP_Employee.Query.Search(Connection, Transaction, new ORM_CMN_BPT_EMP_Employee.Query { BusinessParticipant_RefID = Parameter.CMN_BPT_BusinessParticipantID, IsDeleted = false, Tenant_RefID = securityTicket.TenantID }).FirstOrDefault(); var oficeToDoctorList = ORM_CMN_BPT_EMP_Employee_2_Office.Query.Search(Connection, Transaction, new ORM_CMN_BPT_EMP_Employee_2_Office.Query { CMN_BPT_EMP_Employee_RefID = emp.CMN_BPT_EMP_EmployeeID, IsDeleted = false, Tenant_RefID = securityTicket.TenantID }); if (Parameter.UpdateSlots) { foreach (var o2d in oficeToDoctorList) { cls_CreateUpdate_Slots_for_Practice.Invoke(Connection, Transaction, new P_L5S_SUSfP_1708() { PracticeID = o2d.CMN_STR_Office_RefID }, securityTicket); } } return(returnValue); #endregion UserCode }
protected static FR_L6DE_SDaTT_1355 Execute(DbConnection Connection, DbTransaction Transaction, P_L6DE_SDaTT_1355 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null) { #region UserCode var returnValue = new FR_L6DE_SDaTT_1355(); returnValue.Result = new L6DE_SDaTT_1355(); returnValue.Result.BaseData = new L5MHC_SDIwDC_1040(); Parameter.BaseData.UpdateSlots = Parameter.UpdateSlots; var prevOfficeID = Guid.Empty; if (Parameter.BaseData.BaseData.PPS_DEV_Device_InstanceID != Guid.Empty) { ORM_PPS_DEV_Device_Instance_OfficeLocation location = ORM_PPS_DEV_Device_Instance_OfficeLocation.Query.Search(Connection, Transaction, new ORM_PPS_DEV_Device_Instance_OfficeLocation.Query() { IsDeleted = false, Tenant_RefID = securityTicket.TenantID, DeviceInstance_RefID = Parameter.BaseData.BaseData.PPS_DEV_Device_InstanceID }).SingleOrDefault(); if (location != null) { prevOfficeID = location.CMN_STR_Office_RefID; } } var instanceID = cls_Save_DeviceInstance_withDeleteCheck.Invoke(Connection, Transaction, Parameter.BaseData, securityTicket).Result; if (Parameter.BaseData.BaseData.IsDelete) { returnValue.Result.BaseData = instanceID; } else { if (Parameter.AvailabilityDate != null) { foreach (var timeItem in Parameter.AvailabilityDate) { var availabilityType = ORM_CMN_CAL_AVA_Availability_Type.Query.Search(Connection, Transaction, new ORM_CMN_CAL_AVA_Availability_Type.Query() { Tenant_RefID = securityTicket.TenantID, IsDeleted = false, GlobalPropertyMatchingID = timeItem.Type }).First(); #region Delete if (timeItem.IsDeleted) { ORM_PPS_DEV_Device_Instance_Availability.Query.SoftDelete(Connection, Transaction, new ORM_PPS_DEV_Device_Instance_Availability.Query() { Tenant_RefID = securityTicket.TenantID, IsDeleted = false, CMN_CAL_AVA_Availability_RefID = timeItem.AvailabilityID, }); } #endregion else { var assignment = ORM_PPS_DEV_Device_Instance_Availability.Query.Search(Connection, Transaction, new ORM_PPS_DEV_Device_Instance_Availability.Query() { Tenant_RefID = securityTicket.TenantID, IsDeleted = false, CMN_CAL_AVA_Availability_RefID = timeItem.AvailabilityID, DeviceInstance_RefID = instanceID.ID }).SingleOrDefault(); #region Save if (assignment == null) { assignment = new ORM_PPS_DEV_Device_Instance_Availability(); assignment.PPS_DEV_Device_Instance_AvailabilityID = Guid.NewGuid(); assignment.CMN_CAL_AVA_Availability_RefID = timeItem.AvailabilityID; assignment.DeviceInstance_RefID = instanceID.ID; assignment.Tenant_RefID = securityTicket.TenantID; assignment.Creation_Timestamp = DateTime.Now; assignment.Save(Connection, Transaction); var availability = new ORM_CMN_CAL_AVA_Availability(); availability.CMN_CAL_AVA_AvailabilityID = assignment.CMN_CAL_AVA_Availability_RefID; availability.Tenant_RefID = securityTicket.TenantID; availability.Creation_Timestamp = DateTime.Now; availability.AvailabilityType_RefID = availabilityType.CMN_CAL_AVA_Availability_TypeID; availability.IsAvailabilityExclusionItem = timeItem.IsException; availability.Save(Connection, Transaction); Guid EventId = Guid.NewGuid(); var date = new ORM_CMN_CAL_AVA_Date(); date.CMN_CAL_AVA_DateID = Guid.NewGuid(); date.Availability_RefID = availability.CMN_CAL_AVA_AvailabilityID; date.CMN_CAL_Event_RefID = EventId; date.DateName = timeItem.AvailabilityDate_Name; date.DateComment = timeItem.Reason; date.Tenant_RefID = securityTicket.TenantID; date.Creation_Timestamp = DateTime.Now; date.Save(Connection, Transaction); var events = new ORM_CMN_CAL_Event(); events.CMN_CAL_EventID = EventId; events.IsRepetitive = timeItem.IsRepetitive; events.StartTime = timeItem.AvailabilityDate_From; events.EndTime = timeItem.AvailabilityDate_To; events.Tenant_RefID = securityTicket.TenantID; events.Creation_Timestamp = DateTime.Now; events.Repetition_RefID = Guid.NewGuid(); events.Save(Connection, Transaction); if (timeItem.IsRepetitive) { events.Repetition_RefID = Guid.NewGuid(); var repetitions = new ORM_CMN_CAL_Repetition(); repetitions.CMN_CAL_RepetitionID = events.Repetition_RefID; repetitions.IsMonthly = timeItem.IsMontly; repetitions.IsWeekly = timeItem.IsWeekly; repetitions.IsDaily = timeItem.IsDaily; repetitions.IsYearly = timeItem.IsYearly; repetitions.Tenant_RefID = securityTicket.TenantID; repetitions.Creation_Timestamp = DateTime.Now; repetitions.Save(Connection, Transaction); if (timeItem.IsWeekly) { var repetitionWeekly = new ORM_CMN_CAL_RepetitionPatterns_Weekly(); repetitionWeekly.CMN_CAL_RepetitionPattern_WeeklyID = Guid.NewGuid(); repetitionWeekly.Repetition_RefID = repetitions.CMN_CAL_RepetitionID; repetitionWeekly.Tenant_RefID = securityTicket.TenantID; repetitionWeekly.Creation_Timestamp = DateTime.Now; repetitionWeekly.HasRepeatingOn_Fridays = timeItem.HasRepeatingOn_Fridays; repetitionWeekly.HasRepeatingOn_Mondays = timeItem.HasRepeatingOn_Mondays; repetitionWeekly.HasRepeatingOn_Saturdays = timeItem.HasRepeatingOn_Saturdays; repetitionWeekly.HasRepeatingOn_Sundays = timeItem.HasRepeatingOn_Sundays; repetitionWeekly.HasRepeatingOn_Thursdays = timeItem.HasRepeatingOn_Thursdays; repetitionWeekly.HasRepeatingOn_Tuesdays = timeItem.HasRepeatingOn_Tuesdays; repetitionWeekly.HasRepeatingOn_Wednesdays = timeItem.HasRepeatingOn_Wednesdays; repetitionWeekly.Save(Connection, Transaction); } if (timeItem.IsMontly) { var repetitionMontly = new ORM_CMN_CAL_RepetitionPatterns_Monthly(); repetitionMontly.CMN_CAL_RepetitionPattern_MonthlyID = Guid.NewGuid(); repetitionMontly.Repetition_RefID = repetitions.CMN_CAL_RepetitionID; repetitionMontly.Tenant_RefID = securityTicket.TenantID; repetitionMontly.Creation_Timestamp = DateTime.Now; repetitionMontly.Save(Connection, Transaction); } if (timeItem.IsDaily) { var repetitionDaily = new ORM_CMN_CAL_RepetitionPatterns_Daily(); repetitionDaily.CMN_CAL_RepetitionPattern_DailyID = Guid.NewGuid(); repetitionDaily.Repetition_RefID = repetitions.CMN_CAL_RepetitionID; repetitionDaily.Tenant_RefID = securityTicket.TenantID; repetitionDaily.Creation_Timestamp = DateTime.Now; repetitionDaily.Save(Connection, Transaction); } if (timeItem.IsYearly) { var repetitionYearly = new ORM_CMN_CAL_RepetitionPatterns_Yearly(); repetitionYearly.CMN_CAL_RepetitionPattern_YearlyID = Guid.NewGuid(); repetitionYearly.Repetition_RefID = repetitions.CMN_CAL_RepetitionID; repetitionYearly.Tenant_RefID = securityTicket.TenantID; repetitionYearly.Creation_Timestamp = DateTime.Now; repetitionYearly.Save(Connection, Transaction); } } events.Save(Connection, Transaction); } #endregion #region Edit else { var date = ORM_CMN_CAL_AVA_Date.Query.Search(Connection, Transaction, new ORM_CMN_CAL_AVA_Date.Query() { Availability_RefID = assignment.CMN_CAL_AVA_Availability_RefID, IsDeleted = false, Tenant_RefID = securityTicket.TenantID }).Single(); date.DateName = timeItem.AvailabilityDate_Name; date.DateComment = timeItem.Reason; date.Save(Connection, Transaction); var Events = ORM_CMN_CAL_Event.Query.Search(Connection, Transaction, new ORM_CMN_CAL_Event.Query() { CMN_CAL_EventID = date.CMN_CAL_Event_RefID, Tenant_RefID = securityTicket.TenantID, IsDeleted = false }).Single(); Events.IsRepetitive = timeItem.IsRepetitive; Events.IsWholeDayEvent = timeItem.IsWholeDay; Events.StartTime = timeItem.AvailabilityDate_From; Events.EndTime = timeItem.AvailabilityDate_To; var repetitions = ORM_CMN_CAL_Repetition.Query.Search(Connection, Transaction, new ORM_CMN_CAL_Repetition.Query() { CMN_CAL_RepetitionID = Events.Repetition_RefID, Tenant_RefID = securityTicket.TenantID, IsDeleted = false }).SingleOrDefault(); if (repetitions != null) { repetitions.IsDeleted = true; repetitions.Save(Connection, Transaction); if (repetitions.IsWeekly) { ORM_CMN_CAL_RepetitionPatterns_Weekly.Query.SoftDelete(Connection, Transaction, new ORM_CMN_CAL_RepetitionPatterns_Weekly.Query() { IsDeleted = false, Tenant_RefID = securityTicket.TenantID, Repetition_RefID = repetitions.CMN_CAL_RepetitionID, }); } if (repetitions.IsMonthly) { ORM_CMN_CAL_RepetitionPatterns_Monthly.Query.SoftDelete(Connection, Transaction, new ORM_CMN_CAL_RepetitionPatterns_Monthly.Query() { Repetition_RefID = repetitions.CMN_CAL_RepetitionID, Tenant_RefID = securityTicket.TenantID, IsDeleted = false }); } if (repetitions.IsDaily) { ORM_CMN_CAL_RepetitionPatterns_Daily.Query.SoftDelete(Connection, Transaction, new ORM_CMN_CAL_RepetitionPatterns_Daily.Query() { Repetition_RefID = repetitions.CMN_CAL_RepetitionID, IsDeleted = false, Tenant_RefID = securityTicket.TenantID }); } if (repetitions.IsYearly) { ORM_CMN_CAL_RepetitionPatterns_Yearly.Query.SoftDelete(Connection, Transaction, new ORM_CMN_CAL_RepetitionPatterns_Yearly.Query() { Tenant_RefID = securityTicket.TenantID, IsDeleted = false, Repetition_RefID = repetitions.CMN_CAL_RepetitionID }); } } if (timeItem.IsRepetitive) { Events.Repetition_RefID = Guid.NewGuid(); repetitions = new ORM_CMN_CAL_Repetition(); repetitions.CMN_CAL_RepetitionID = Events.Repetition_RefID; repetitions.IsMonthly = timeItem.IsMontly; repetitions.IsWeekly = timeItem.IsWeekly; repetitions.IsDaily = timeItem.IsDaily; repetitions.IsYearly = timeItem.IsYearly; repetitions.Tenant_RefID = securityTicket.TenantID; repetitions.Creation_Timestamp = DateTime.Now; repetitions.Save(Connection, Transaction); if (timeItem.IsWeekly) { var repetitionWeekly = new ORM_CMN_CAL_RepetitionPatterns_Weekly(); repetitionWeekly.CMN_CAL_RepetitionPattern_WeeklyID = Guid.NewGuid(); repetitionWeekly.HasRepeatingOn_Fridays = timeItem.HasRepeatingOn_Fridays; repetitionWeekly.HasRepeatingOn_Mondays = timeItem.HasRepeatingOn_Mondays; repetitionWeekly.HasRepeatingOn_Saturdays = timeItem.HasRepeatingOn_Saturdays; repetitionWeekly.HasRepeatingOn_Sundays = timeItem.HasRepeatingOn_Sundays; repetitionWeekly.HasRepeatingOn_Thursdays = timeItem.HasRepeatingOn_Thursdays; repetitionWeekly.HasRepeatingOn_Tuesdays = timeItem.HasRepeatingOn_Tuesdays; repetitionWeekly.HasRepeatingOn_Wednesdays = timeItem.HasRepeatingOn_Wednesdays; repetitionWeekly.Repetition_RefID = repetitions.CMN_CAL_RepetitionID; repetitionWeekly.Tenant_RefID = securityTicket.TenantID; repetitionWeekly.Creation_Timestamp = DateTime.Now; repetitionWeekly.Save(Connection, Transaction); } if (timeItem.IsMontly) { var repetitionMontly = new ORM_CMN_CAL_RepetitionPatterns_Monthly(); repetitionMontly.CMN_CAL_RepetitionPattern_MonthlyID = Guid.NewGuid(); repetitionMontly.Repetition_RefID = repetitions.CMN_CAL_RepetitionID; repetitionMontly.Tenant_RefID = securityTicket.TenantID; repetitionMontly.Creation_Timestamp = DateTime.Now; repetitionMontly.Save(Connection, Transaction); } if (timeItem.IsDaily) { var repetitionDaily = new ORM_CMN_CAL_RepetitionPatterns_Daily(); repetitionDaily.CMN_CAL_RepetitionPattern_DailyID = Guid.NewGuid(); repetitionDaily.Repetition_RefID = repetitions.CMN_CAL_RepetitionID; repetitionDaily.Tenant_RefID = securityTicket.TenantID; repetitionDaily.Creation_Timestamp = DateTime.Now; repetitionDaily.Save(Connection, Transaction); } if (timeItem.IsYearly) { var repetitionYearly = new ORM_CMN_CAL_RepetitionPatterns_Yearly(); repetitionYearly.CMN_CAL_RepetitionPattern_YearlyID = Guid.NewGuid(); repetitionYearly.Repetition_RefID = repetitions.CMN_CAL_RepetitionID; repetitionYearly.Tenant_RefID = securityTicket.TenantID; repetitionYearly.Creation_Timestamp = DateTime.Now; repetitionYearly.Save(Connection, Transaction); } } Events.Save(Connection, Transaction); } #endregion } } returnValue.Result.BaseData = instanceID; } } if (Parameter.UpdateSlots) { if (!Parameter.BaseData.BaseData.IsDelete) { cls_CreateUpdate_Slots_for_Practice.Invoke(Connection, Transaction, new P_L5S_SUSfP_1708() { PracticeID = Parameter.BaseData.BaseData.OfficeID }, securityTicket); if (prevOfficeID != Guid.Empty && prevOfficeID != Parameter.BaseData.BaseData.OfficeID) { cls_CreateUpdate_Slots_for_Practice.Invoke(Connection, Transaction, new P_L5S_SUSfP_1708() { PracticeID = prevOfficeID }, securityTicket); } } else { if (prevOfficeID != Guid.Empty) { cls_CreateUpdate_Slots_for_Practice.Invoke(Connection, Transaction, new P_L5S_SUSfP_1708() { PracticeID = prevOfficeID }, securityTicket); } } } return(returnValue); #endregion UserCode }
protected static FR_Guid Execute(DbConnection Connection, DbTransaction Transaction, P_L3EV_SSE_1048 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null) { #region UserCode var returnValue = new FR_Guid(); //Put your code here if (Parameter.CalendarInstanceID == Guid.Empty) { ORM_CMN_Tenant tenant = new ORM_CMN_Tenant(); if (securityTicket.TenantID != Guid.Empty) { var result = tenant.Load(Connection, Transaction, securityTicket.TenantID); if (result.Status != FR_Status.Success || tenant.CMN_TenantID == Guid.Empty) { var error = new FR_Guid(); error.ErrorMessage = "No Such ID"; error.Status = FR_Status.Error_Internal; return(error); } } if (tenant.CMN_CAL_CalendarInstance_RefID == Guid.Empty) { ORM_CMN_CAL_CalendarInstance instance = new ORM_CMN_CAL_CalendarInstance(); instance.WeekStartsOnDay = 1; instance.Save(Connection, Transaction); tenant.CMN_CAL_CalendarInstance_RefID = instance.CMN_CAL_CalendarInstanceID; tenant.Save(Connection, Transaction); } } ORM_CMN_CAL_Event calendarEvent = new ORM_CMN_CAL_Event(); if (Parameter.CMN_CAL_EventID != Guid.Empty) { var result = calendarEvent.Load(Connection, Transaction, Parameter.CMN_CAL_EventID); if (result.Status != FR_Status.Success || calendarEvent.CMN_CAL_EventID == Guid.Empty) { var error = new FR_Guid(); error.ErrorMessage = "No Such ID"; error.Status = FR_Status.Error_Internal; return(error); } } calendarEvent.CalendarInstance_RefID = Parameter.CalendarInstanceID; calendarEvent.EndTime = Parameter.EndTime; calendarEvent.IsRepetitive = Parameter.IsRepetitive; calendarEvent.R_EventDuration_sec = Parameter.R_EventDuration_sec; calendarEvent.StartTime = Parameter.StartTime; calendarEvent.Tenant_RefID = securityTicket.TenantID; calendarEvent.CalendarInstance_RefID = Parameter.CalendarInstanceID; if (Parameter.IsRepetitive) { ORM_CMN_CAL_Repetition repetition = new ORM_CMN_CAL_Repetition(); if (Parameter.CMN_CAL_RepetitionID != Guid.Empty) { var result = repetition.Load(Connection, Transaction, Parameter.CMN_CAL_RepetitionID); if (result.Status != FR_Status.Success || repetition.CMN_CAL_RepetitionID == Guid.Empty) { var error = new FR_Guid(); error.ErrorMessage = "No Such ID"; error.Status = FR_Status.Error_Internal; return(error); } } repetition.IsDaily = Parameter.IsDaily; repetition.IsMonthly = Parameter.IsMonthly; repetition.IsWeekly = Parameter.IsWeekly; repetition.IsYearly = Parameter.IsYearly; repetition.R_CronExpression = Parameter.R_CronExpression; repetition.Tenant_RefID = securityTicket.TenantID; repetition.Save(Connection, Transaction); calendarEvent.IsRepetitive = true; calendarEvent.Repetition_RefID = repetition.CMN_CAL_RepetitionID; ORM_CMN_CAL_Repetition_Ranx repetitionRange = new ORM_CMN_CAL_Repetition_Ranx(); if (Parameter.repetitionRangesCMN_CAL_Repetition_RangeID != Guid.Empty) { var result = repetitionRange.Load(Connection, Transaction, Parameter.repetitionRangesCMN_CAL_Repetition_RangeID); if (result.Status != FR_Status.Success || repetitionRange.CMN_CAL_Repetition_RangeID == Guid.Empty) { var error = new FR_Guid(); error.ErrorMessage = "No Such ID"; error.Status = FR_Status.Error_Internal; return(error); } } repetitionRange.End_AfterSpecifiedOccurrences = Parameter.repetitionRangesEnd_AfterSpecifiedOccurrences; repetitionRange.End_ByDate = Parameter.repetitionRangesEnd_ByDate; repetitionRange.HasEndType_DateTime = Parameter.repetitionRangesHasEndType_DateTime; repetitionRange.HasEndType_NoEndDate = Parameter.repetitionRangesHasEndType_NoEndDate; repetitionRange.HasEndType_Occurrence = Parameter.repetitionRangesHasEndType_Occurrence; repetitionRange.Repetition_RefID = repetition.CMN_CAL_RepetitionID; repetitionRange.Tenant_RefID = securityTicket.TenantID; repetitionRange.Save(Connection, Transaction); if (Parameter.IsDaily) { ORM_CMN_CAL_RepetitionPatterns_Daily daily = new ORM_CMN_CAL_RepetitionPatterns_Daily(); if (Parameter.dailyCMN_CAL_RepetitionPattern_DailyID != Guid.Empty) { var result = daily.Load(Connection, Transaction, Parameter.dailyCMN_CAL_RepetitionPattern_DailyID); if (result.Status != FR_Status.Success || daily.CMN_CAL_RepetitionPattern_DailyID == Guid.Empty) { var error = new FR_Guid(); error.ErrorMessage = "No Such ID"; error.Status = FR_Status.Error_Internal; return(error); } } daily.Repetition_EveryNumberOfDays = Parameter.dailyRepetition_EveryNumberOfDays; daily.Repetition_RefID = repetition.CMN_CAL_RepetitionID; daily.Tenant_RefID = securityTicket.TenantID; daily.Save(Connection, Transaction); } else if (Parameter.IsWeekly) { ORM_CMN_CAL_RepetitionPatterns_Weekly weekly = new ORM_CMN_CAL_RepetitionPatterns_Weekly(); if (Parameter.weeklyCMN_CAL_RepetitionPattern_WeeklyID != Guid.Empty) { var result = weekly.Load(Connection, Transaction, Parameter.weeklyCMN_CAL_RepetitionPattern_WeeklyID); if (result.Status != FR_Status.Success || weekly.CMN_CAL_RepetitionPattern_WeeklyID == Guid.Empty) { var error = new FR_Guid(); error.ErrorMessage = "No Such ID"; error.Status = FR_Status.Error_Internal; return(error); } } weekly.HasRepeatingOn_Fridays = Parameter.weeklyHasRepeatingOn_Fridays; weekly.HasRepeatingOn_Mondays = Parameter.weeklyHasRepeatingOn_Mondays; weekly.HasRepeatingOn_Saturdays = Parameter.weeklyHasRepeatingOn_Saturdays; weekly.HasRepeatingOn_Sundays = Parameter.weeklyHasRepeatingOn_Sundays; weekly.HasRepeatingOn_Thursdays = Parameter.weeklyHasRepeatingOn_Thursdays; weekly.HasRepeatingOn_Tuesdays = Parameter.weeklyHasRepeatingOn_Tuesdays; weekly.HasRepeatingOn_Wednesdays = Parameter.weeklyHasRepeatingOn_Wednesdays; weekly.Repetition_EveryNumberOfWeeks = Parameter.weeklyRepetition_EveryNumberOfWeeks; weekly.Repetition_RefID = repetition.CMN_CAL_RepetitionID; weekly.Tenant_RefID = securityTicket.TenantID; weekly.Save(Connection, Transaction); } else if (Parameter.IsMonthly) { ORM_CMN_CAL_RepetitionPatterns_Monthly monthly = new ORM_CMN_CAL_RepetitionPatterns_Monthly(); if (Parameter.monthlyCMN_CAL_RepetitionPattern_MonthlyID != Guid.Empty) { var result = monthly.Load(Connection, Transaction, Parameter.monthlyCMN_CAL_RepetitionPattern_MonthlyID); if (result.Status != FR_Status.Success || monthly.CMN_CAL_RepetitionPattern_MonthlyID == Guid.Empty) { var error = new FR_Guid(); error.ErrorMessage = "No Such ID"; error.Status = FR_Status.Error_Internal; return(error); } } monthly.Repetition_EveryNumberOfMonths = Parameter.monthlyRepetition_EveryNumberOfMonths; monthly.Repetition_RefID = repetition.CMN_CAL_RepetitionID; monthly.Tenant_RefID = securityTicket.TenantID; if (Parameter.monthlyIsRelative) { monthly.IsFixed = false; monthly.IsRelative = true; ORM_CMN_CAL_RepetitionPatterns_Relative relative = new ORM_CMN_CAL_RepetitionPatterns_Relative(); if (Parameter.relativeCMN_CAL_RepetitionPattern_RelativeID != Guid.Empty) { var result = relative.Load(Connection, Transaction, Parameter.relativeCMN_CAL_RepetitionPattern_RelativeID); if (result.Status != FR_Status.Success || relative.CMN_CAL_RepetitionPattern_RelativeID == Guid.Empty) { var error = new FR_Guid(); error.ErrorMessage = "No Such ID"; error.Status = FR_Status.Error_Internal; return(error); } } relative.IsFriday = Parameter.relativeIsFriday; relative.IsMonday = Parameter.relativeIsMonday; relative.IsSaturday = Parameter.relativeIsSaturday; relative.IsSunday = Parameter.relativeIsSunday; relative.IsThursday = Parameter.relativeIsThursday; relative.IsTuesday = Parameter.relativeIsTuesday; relative.IsWednesday = Parameter.relativeIsWednesday; relative.IsWeekDay = Parameter.relativeIsWeekDay; relative.IsWeekendDay = Parameter.relativeIsWeekendDay; relative.Ordinal = Parameter.relativeOrdinal; relative.Tenant_RefID = securityTicket.TenantID; relative.Save(Connection, Transaction); monthly.IfRelative_RepetitionPattern_RefID = relative.CMN_CAL_RepetitionPattern_RelativeID; } else { monthly.IsRelative = false; monthly.IsFixed = true; monthly.IfFixed_DayOfMonth = Parameter.monthlyIfFixed_DayOfMonth; } monthly.Save(Connection, Transaction); } else { ORM_CMN_CAL_RepetitionPatterns_Yearly yearly = new ORM_CMN_CAL_RepetitionPatterns_Yearly(); if (Parameter.yearlyCMN_CAL_RepetitionPattern_YearlyID != Guid.Empty) { var result = yearly.Load(Connection, Transaction, Parameter.yearlyCMN_CAL_RepetitionPattern_YearlyID); if (result.Status != FR_Status.Success || yearly.CMN_CAL_RepetitionPattern_YearlyID == Guid.Empty) { var error = new FR_Guid(); error.ErrorMessage = "No Such ID"; error.Status = FR_Status.Error_Internal; return(error); } } yearly.Repetition_EveryNumberOfYears = Parameter.yearlyRepetition_EveryNumberOfYears; yearly.Repetition_Month = Parameter.yearlyRepetition_Month; yearly.Repetition_RefID = repetition.CMN_CAL_RepetitionID; yearly.Tenant_RefID = securityTicket.TenantID; if (Parameter.yearlyIsRelative) { yearly.IsRelative = true; yearly.IsFixed = false; ORM_CMN_CAL_RepetitionPatterns_Relative relative = new ORM_CMN_CAL_RepetitionPatterns_Relative(); if (Parameter.relativeCMN_CAL_RepetitionPattern_RelativeID != Guid.Empty) { var result = relative.Load(Connection, Transaction, Parameter.relativeCMN_CAL_RepetitionPattern_RelativeID); if (result.Status != FR_Status.Success || relative.CMN_CAL_RepetitionPattern_RelativeID == Guid.Empty) { var error = new FR_Guid(); error.ErrorMessage = "No Such ID"; error.Status = FR_Status.Error_Internal; return(error); } } relative.IsFriday = Parameter.relativeIsFriday; relative.IsMonday = Parameter.relativeIsMonday; relative.IsSaturday = Parameter.relativeIsSaturday; relative.IsSunday = Parameter.relativeIsSunday; relative.IsThursday = Parameter.relativeIsThursday; relative.IsTuesday = Parameter.relativeIsTuesday; relative.IsWednesday = Parameter.relativeIsWednesday; relative.IsWeekDay = Parameter.relativeIsWeekDay; relative.IsWeekendDay = Parameter.relativeIsWeekendDay; relative.Ordinal = Parameter.relativeOrdinal; relative.Tenant_RefID = securityTicket.TenantID; relative.Save(Connection, Transaction); yearly.IfRelative_RepetitionPattern_RefID = relative.CMN_CAL_RepetitionPattern_RelativeID; yearly.IsFixed = false; } else { yearly.IsRelative = false; yearly.IsFixed = true; yearly.IfFixed_DayOfMonth = Parameter.yearlyIfFixed_DayOfMonth; } yearly.Save(Connection, Transaction); } } else { calendarEvent.IsRepetitive = false; calendarEvent.Repetition_RefID = Guid.Empty; } calendarEvent.Save(Connection, Transaction); ORM_CMN_STR_SCE_StructureCalendarEvent structureEvent = new ORM_CMN_STR_SCE_StructureCalendarEvent(); if (Parameter.CMN_STR_SCE_StructureCalendarEventID != Guid.Empty) { var result = structureEvent.Load(Connection, Transaction, Parameter.CMN_STR_SCE_StructureCalendarEventID); if (result.Status != FR_Status.Success || structureEvent.CMN_STR_SCE_StructureCalendarEventID == Guid.Empty) { var error = new FR_Guid(); error.ErrorMessage = "No Such ID"; error.Status = FR_Status.Error_Internal; return(error); } } if (Parameter.IsHavingCapacityRestriction) { ORM_CMN_STR_SCE_CapacityRestriction capacityRestriction = new ORM_CMN_STR_SCE_CapacityRestriction(); if (Parameter.CMN_STR_SCE_CapacityRestrictionID != Guid.Empty) { var result = capacityRestriction.Load(Connection, Transaction, Parameter.CMN_STR_SCE_CapacityRestrictionID); if (result.Status != FR_Status.Success || capacityRestriction.CMN_STR_SCE_CapacityRestrictionID == Guid.Empty) { var error = new FR_Guid(); error.ErrorMessage = "No Such ID"; error.Status = FR_Status.Error_Internal; return(error); } } capacityRestriction.IsValueCalculated_InHeadCount = Parameter.IsValueCalculated_InHeadCount; capacityRestriction.IsValueCalculated_InPercentage = Parameter.IsValueCalculated_InPercentage; capacityRestriction.IsValueCalculated_InWorkingHours = Parameter.IsValueCalculated_InWorkingHours; capacityRestriction.CapacityRestrictionType_RefID = Parameter.CMN_STR_SCE_CapacityRestriction_TypeID; capacityRestriction.Tenant_RefID = securityTicket.TenantID; capacityRestriction.ValueCalculated = Parameter.ValueCalculated; capacityRestriction.Save(Connection, Transaction); structureEvent.IfHavingCapacityRestriction_Restriction_RefID = capacityRestriction.CMN_STR_SCE_CapacityRestrictionID; structureEvent.IsHavingCapacityRestriction = true; } else { structureEvent.IsHavingCapacityRestriction = false; } var eventType = new ORM_CMN_STR_SCE_StructureCalendarEvent_Type(); var resultForType = eventType.Load(Connection, Transaction, Parameter.StructureCalendarEvent_Type_RefID); if (resultForType.Status != FR_Status.Success || eventType.CMN_STR_SCE_StructureCalendarEvent_TypeID == Guid.Empty) { var error = new FR_Guid(); error.ErrorMessage = "No Such ID"; error.Status = FR_Status.Error_Internal; return(error); } structureEvent.IsWorkingDayEvent = eventType.IsWorkingDay; structureEvent.IsWorkingHalfDayEvent = eventType.IsHalfWorkingDay; structureEvent.IsNonWorkingDay = eventType.IsNonWorkingDay; structureEvent.CMN_CAL_Event_RefID = calendarEvent.CMN_CAL_EventID; structureEvent.StructureCalendarEvent_Type_RefID = Parameter.StructureCalendarEvent_Type_RefID; structureEvent.R_CalendarInstance_RefID = Parameter.CalendarInstanceID; structureEvent.StructureEvent_Description = Parameter.StructureEvent_Description; structureEvent.StructureEvent_Name = Parameter.StructureEvent_Name; structureEvent.Tenant_RefID = securityTicket.TenantID; structureEvent.IsEvent_ImportedFromTemplate = Parameter.IsEvent_ImportedFromTemplate; structureEvent.IsBusinessDay = Parameter.IsBusinessDay; structureEvent.Save(Connection, Transaction); returnValue.Result = structureEvent.CMN_STR_SCE_StructureCalendarEventID; ORM_CMN_STR_SCE_ForbiddenLeaveType whereInstanceForbiddenLeaveType = CSV2Core_MySQL.Support.SQLClassFilter.GetDefaultInstance <ORM_CMN_STR_SCE_ForbiddenLeaveType>(); whereInstanceForbiddenLeaveType.CMN_STR_SCE_StructureCalendarEvent_RefID = structureEvent.CMN_STR_SCE_StructureCalendarEventID; CSV2Core_MySQL.Support.SQLClassFilter.Delete(Connection, Transaction, whereInstanceForbiddenLeaveType); foreach (var forbidenLeaveType in Parameter.forbidenLeaveTypes) { ORM_CMN_STR_SCE_ForbiddenLeaveType item = new ORM_CMN_STR_SCE_ForbiddenLeaveType(); if (forbidenLeaveType.CMN_STR_SCE_ForbiddenLeaveTypeID != Guid.Empty) { var result = item.Load(Connection, Transaction, forbidenLeaveType.CMN_STR_SCE_ForbiddenLeaveTypeID); if (result.Status != FR_Status.Success || item.CMN_STR_SCE_ForbiddenLeaveTypeID == Guid.Empty) { var error = new FR_Guid(); error.ErrorMessage = "No Such ID"; error.Status = FR_Status.Error_Internal; return(error); } } item.CMN_BPT_STA_AbsenceReason_RefID = forbidenLeaveType.CMN_BPT_STA_AbsenceReasonID; item.CMN_STR_SCE_StructureCalendarEvent_RefID = structureEvent.CMN_STR_SCE_StructureCalendarEventID; item.Tenant_RefID = securityTicket.TenantID; item.Save(Connection, Transaction); } return(returnValue); #endregion UserCode }
protected static FR_Guid Execute(DbConnection Connection, DbTransaction Transaction, P_L5MHC_SDwTT_1419 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null) { #region UserCode var returnValue = new FR_Guid(); var instanceID = cls_Save_DeviceInstance.Invoke(Connection, Transaction, Parameter.BaseData, securityTicket).Result; if (Parameter.Availabilities != null) { foreach (var availability in Parameter.Availabilities) { if (!availability.IsDelete) { ORM_PPS_DEV_Device_Instance_Availability assignemnt; if (availability.CMN_CAL_AVA_AvailabilityID != Guid.Empty) { assignemnt = ORM_PPS_DEV_Device_Instance_Availability.Query.Search(Connection, Transaction, new ORM_PPS_DEV_Device_Instance_Availability.Query() { CMN_CAL_AVA_Availability_RefID = availability.CMN_CAL_AVA_AvailabilityID, DeviceInstance_RefID = instanceID, IsDeleted = false, Tenant_RefID = securityTicket.TenantID }).Single(); } else { assignemnt = new ORM_PPS_DEV_Device_Instance_Availability(); assignemnt.PPS_DEV_Device_Instance_AvailabilityID = Guid.NewGuid(); assignemnt.DeviceInstance_RefID = instanceID; assignemnt.CMN_CAL_AVA_Availability_RefID = Guid.NewGuid(); assignemnt.Tenant_RefID = securityTicket.TenantID; assignemnt.Save(Connection, Transaction); } ORM_CMN_CAL_AVA_Availability ORM_CMN_CAL_AVA_Availability = ORM_CMN_CAL_AVA_Availability.Query.Search(Connection, Transaction, new ORM_CMN_CAL_AVA_Availability.Query() { CMN_CAL_AVA_AvailabilityID = assignemnt.CMN_CAL_AVA_Availability_RefID, IsDeleted = false, Tenant_RefID = securityTicket.TenantID }).SingleOrDefault(); if (ORM_CMN_CAL_AVA_Availability == null) { ORM_CMN_CAL_AVA_Availability = new ORM_CMN_CAL_AVA_Availability(); ORM_CMN_CAL_AVA_Availability.CMN_CAL_AVA_AvailabilityID = assignemnt.CMN_CAL_AVA_Availability_RefID; ORM_CMN_CAL_AVA_Availability.Tenant_RefID = securityTicket.TenantID; } ORM_CMN_CAL_AVA_Availability.Save(Connection, Transaction); ORM_CMN_CAL_AVA_Date date = ORM_CMN_CAL_AVA_Date.Query.Search(Connection, Transaction, new ORM_CMN_CAL_AVA_Date.Query() { Availability_RefID = ORM_CMN_CAL_AVA_Availability.CMN_CAL_AVA_AvailabilityID, IsDeleted = false, Tenant_RefID = securityTicket.TenantID }).SingleOrDefault(); if (date == null) { date = new ORM_CMN_CAL_AVA_Date(); date.CMN_CAL_AVA_DateID = Guid.NewGuid(); date.Tenant_RefID = securityTicket.TenantID; date.Availability_RefID = ORM_CMN_CAL_AVA_Availability.CMN_CAL_AVA_AvailabilityID; date.CMN_CAL_Event_RefID = Guid.NewGuid(); } date.DateName = availability.Name; date.Save(Connection, Transaction); ORM_CMN_CAL_Event eventItem = ORM_CMN_CAL_Event.Query.Search(Connection, Transaction, new ORM_CMN_CAL_Event.Query() { CMN_CAL_EventID = date.CMN_CAL_Event_RefID, Tenant_RefID = securityTicket.TenantID, IsDeleted = false }).SingleOrDefault(); if (eventItem == null) { eventItem = new ORM_CMN_CAL_Event(); eventItem.CMN_CAL_EventID = Guid.NewGuid(); eventItem.Tenant_RefID = securityTicket.TenantID; eventItem.IsRepetitive = true; eventItem.Repetition_RefID = Guid.NewGuid(); } eventItem.IsWholeDayEvent = availability.IsWholeDay; eventItem.StartTime = availability.StartTime; eventItem.EndTime = availability.EndTime; eventItem.Save(Connection, Transaction); ORM_CMN_CAL_Repetition repetition = ORM_CMN_CAL_Repetition.Query.Search(Connection, Transaction, new ORM_CMN_CAL_Repetition.Query() { CMN_CAL_RepetitionID = eventItem.Repetition_RefID, Tenant_RefID = securityTicket.TenantID, IsDeleted = false }).SingleOrDefault(); if (repetition == null) { repetition = new ORM_CMN_CAL_Repetition(); repetition.CMN_CAL_RepetitionID = Guid.NewGuid(); repetition.Tenant_RefID = securityTicket.TenantID; repetition.CMN_CAL_RepetitionID = eventItem.Repetition_RefID; repetition.IsWeekly = true; repetition.Save(Connection, Transaction); } ORM_CMN_CAL_RepetitionPatterns_Weekly weekly = ORM_CMN_CAL_RepetitionPatterns_Weekly.Query.Search(Connection, Transaction, new ORM_CMN_CAL_RepetitionPatterns_Weekly.Query() { Repetition_RefID = repetition.CMN_CAL_RepetitionID, Tenant_RefID = securityTicket.TenantID, IsDeleted = false }).SingleOrDefault(); if (repetition == null) { weekly = new ORM_CMN_CAL_RepetitionPatterns_Weekly(); weekly.CMN_CAL_RepetitionPattern_WeeklyID = Guid.NewGuid(); weekly.Repetition_RefID = repetition.CMN_CAL_RepetitionID; weekly.Tenant_RefID = securityTicket.TenantID; weekly.Save(Connection, Transaction); } } else { var assignemnt = ORM_PPS_DEV_Device_Instance_Availability.Query.Search(Connection, Transaction, new ORM_PPS_DEV_Device_Instance_Availability.Query() { CMN_CAL_AVA_Availability_RefID = availability.CMN_CAL_AVA_AvailabilityID, DeviceInstance_RefID = instanceID, IsDeleted = false, Tenant_RefID = securityTicket.TenantID }).Single(); ORM_CMN_CAL_AVA_Availability ORM_CMN_CAL_AVA_Availability = ORM_CMN_CAL_AVA_Availability.Query.Search(Connection, Transaction, new ORM_CMN_CAL_AVA_Availability.Query() { CMN_CAL_AVA_AvailabilityID = assignemnt.CMN_CAL_AVA_Availability_RefID, IsDeleted = false, Tenant_RefID = securityTicket.TenantID }).Single(); ORM_CMN_CAL_AVA_Date date = ORM_CMN_CAL_AVA_Date.Query.Search(Connection, Transaction, new ORM_CMN_CAL_AVA_Date.Query() { Availability_RefID = ORM_CMN_CAL_AVA_Availability.CMN_CAL_AVA_AvailabilityID, IsDeleted = false, Tenant_RefID = securityTicket.TenantID }).Single(); ORM_CMN_CAL_Event eventItem = ORM_CMN_CAL_Event.Query.Search(Connection, Transaction, new ORM_CMN_CAL_Event.Query() { CMN_CAL_EventID = date.CMN_CAL_Event_RefID, Tenant_RefID = securityTicket.TenantID, IsDeleted = false }).Single(); ORM_CMN_CAL_Repetition repetition = ORM_CMN_CAL_Repetition.Query.Search(Connection, Transaction, new ORM_CMN_CAL_Repetition.Query() { CMN_CAL_RepetitionID = eventItem.Repetition_RefID, Tenant_RefID = securityTicket.TenantID, IsDeleted = false }).Single(); ORM_CMN_CAL_RepetitionPatterns_Weekly weekly = ORM_CMN_CAL_RepetitionPatterns_Weekly.Query.Search(Connection, Transaction, new ORM_CMN_CAL_RepetitionPatterns_Weekly.Query() { Repetition_RefID = repetition.CMN_CAL_RepetitionID, Tenant_RefID = securityTicket.TenantID, IsDeleted = false }).Single(); assignemnt.IsDeleted = true; assignemnt.Save(Connection, Transaction); ORM_CMN_CAL_AVA_Availability.IsDeleted = true; ORM_CMN_CAL_AVA_Availability.Save(Connection, Transaction); date.IsDeleted = true; date.Save(Connection, Transaction); eventItem.IsDeleted = true; eventItem.Save(Connection, Transaction); repetition.IsDeleted = true; repetition.Save(Connection, Transaction); weekly.IsDeleted = true; weekly.Save(Connection, Transaction); } } } if (Parameter.Unavailabilities != null) { foreach (var unavailability in Parameter.Unavailabilities) { if (!unavailability.IsDelete) { ORM_PPS_DEV_Device_Instance_Availability assignemnt; if (unavailability.CMN_CAL_AVA_AvailabilityID != Guid.Empty) { assignemnt = ORM_PPS_DEV_Device_Instance_Availability.Query.Search(Connection, Transaction, new ORM_PPS_DEV_Device_Instance_Availability.Query() { CMN_CAL_AVA_Availability_RefID = unavailability.CMN_CAL_AVA_AvailabilityID, DeviceInstance_RefID = instanceID, IsDeleted = false, Tenant_RefID = securityTicket.TenantID }).Single(); } else { assignemnt = new ORM_PPS_DEV_Device_Instance_Availability(); assignemnt.PPS_DEV_Device_Instance_AvailabilityID = Guid.NewGuid(); assignemnt.DeviceInstance_RefID = instanceID; assignemnt.CMN_CAL_AVA_Availability_RefID = Guid.NewGuid(); assignemnt.Tenant_RefID = securityTicket.TenantID; assignemnt.Save(Connection, Transaction); } ORM_CMN_CAL_AVA_Availability ORM_CMN_CAL_AVA_Availability = ORM_CMN_CAL_AVA_Availability.Query.Search(Connection, Transaction, new ORM_CMN_CAL_AVA_Availability.Query() { CMN_CAL_AVA_AvailabilityID = assignemnt.CMN_CAL_AVA_Availability_RefID, IsDeleted = false, Tenant_RefID = securityTicket.TenantID, IsAvailabilityExclusionItem = true }).SingleOrDefault(); if (ORM_CMN_CAL_AVA_Availability == null) { ORM_CMN_CAL_AVA_Availability = new ORM_CMN_CAL_AVA_Availability(); ORM_CMN_CAL_AVA_Availability.CMN_CAL_AVA_AvailabilityID = assignemnt.CMN_CAL_AVA_Availability_RefID; ORM_CMN_CAL_AVA_Availability.Tenant_RefID = securityTicket.TenantID; ORM_CMN_CAL_AVA_Availability.IsAvailabilityExclusionItem = true; } ORM_CMN_CAL_AVA_Availability.AvailabilityComment = unavailability.Reason; ORM_CMN_CAL_AVA_Availability.Save(Connection, Transaction); ORM_CMN_CAL_AVA_Date date = ORM_CMN_CAL_AVA_Date.Query.Search(Connection, Transaction, new ORM_CMN_CAL_AVA_Date.Query() { Availability_RefID = ORM_CMN_CAL_AVA_Availability.CMN_CAL_AVA_AvailabilityID, IsDeleted = false, Tenant_RefID = securityTicket.TenantID, }).SingleOrDefault(); if (date == null) { date = new ORM_CMN_CAL_AVA_Date(); date.CMN_CAL_AVA_DateID = Guid.NewGuid(); date.Tenant_RefID = securityTicket.TenantID; date.Availability_RefID = ORM_CMN_CAL_AVA_Availability.CMN_CAL_AVA_AvailabilityID; date.CMN_CAL_Event_RefID = Guid.NewGuid(); date.Save(Connection, Transaction); } ORM_CMN_CAL_Event eventItem = ORM_CMN_CAL_Event.Query.Search(Connection, Transaction, new ORM_CMN_CAL_Event.Query() { CMN_CAL_EventID = date.CMN_CAL_Event_RefID, Tenant_RefID = securityTicket.TenantID, IsDeleted = false }).SingleOrDefault(); if (eventItem == null) { eventItem = new ORM_CMN_CAL_Event(); eventItem.CMN_CAL_EventID = Guid.NewGuid(); eventItem.Tenant_RefID = securityTicket.TenantID; eventItem.IsRepetitive = true; eventItem.Repetition_RefID = Guid.NewGuid(); } eventItem.IsWholeDayEvent = unavailability.IsWholeDay; eventItem.StartTime = unavailability.StartTime; eventItem.EndTime = unavailability.EndTime; eventItem.Save(Connection, Transaction); ORM_CMN_CAL_Repetition repetition = ORM_CMN_CAL_Repetition.Query.Search(Connection, Transaction, new ORM_CMN_CAL_Repetition.Query() { CMN_CAL_RepetitionID = eventItem.Repetition_RefID, Tenant_RefID = securityTicket.TenantID, IsDeleted = false }).SingleOrDefault(); if (repetition == null) { repetition = new ORM_CMN_CAL_Repetition(); repetition.CMN_CAL_RepetitionID = Guid.NewGuid(); repetition.Tenant_RefID = securityTicket.TenantID; repetition.CMN_CAL_RepetitionID = eventItem.Repetition_RefID; repetition.IsWeekly = true; repetition.Save(Connection, Transaction); } ORM_CMN_CAL_RepetitionPatterns_Weekly weekly = ORM_CMN_CAL_RepetitionPatterns_Weekly.Query.Search(Connection, Transaction, new ORM_CMN_CAL_RepetitionPatterns_Weekly.Query() { Repetition_RefID = repetition.CMN_CAL_RepetitionID, Tenant_RefID = securityTicket.TenantID, IsDeleted = false }).SingleOrDefault(); if (repetition == null) { weekly = new ORM_CMN_CAL_RepetitionPatterns_Weekly(); weekly.CMN_CAL_RepetitionPattern_WeeklyID = Guid.NewGuid(); weekly.Repetition_RefID = repetition.CMN_CAL_RepetitionID; weekly.Tenant_RefID = securityTicket.TenantID; weekly.Save(Connection, Transaction); } } else { var assignemnt = ORM_PPS_DEV_Device_Instance_Availability.Query.Search(Connection, Transaction, new ORM_PPS_DEV_Device_Instance_Availability.Query() { CMN_CAL_AVA_Availability_RefID = unavailability.CMN_CAL_AVA_AvailabilityID, DeviceInstance_RefID = instanceID, IsDeleted = false, Tenant_RefID = securityTicket.TenantID }).Single(); ORM_CMN_CAL_AVA_Availability ORM_CMN_CAL_AVA_Availability = ORM_CMN_CAL_AVA_Availability.Query.Search(Connection, Transaction, new ORM_CMN_CAL_AVA_Availability.Query() { CMN_CAL_AVA_AvailabilityID = assignemnt.CMN_CAL_AVA_Availability_RefID, IsDeleted = false, Tenant_RefID = securityTicket.TenantID }).Single(); ORM_CMN_CAL_AVA_Date date = ORM_CMN_CAL_AVA_Date.Query.Search(Connection, Transaction, new ORM_CMN_CAL_AVA_Date.Query() { Availability_RefID = ORM_CMN_CAL_AVA_Availability.CMN_CAL_AVA_AvailabilityID, IsDeleted = false, Tenant_RefID = securityTicket.TenantID }).Single(); ORM_CMN_CAL_Event eventItem = ORM_CMN_CAL_Event.Query.Search(Connection, Transaction, new ORM_CMN_CAL_Event.Query() { CMN_CAL_EventID = date.CMN_CAL_Event_RefID, Tenant_RefID = securityTicket.TenantID, IsDeleted = false }).Single(); ORM_CMN_CAL_Repetition repetition = ORM_CMN_CAL_Repetition.Query.Search(Connection, Transaction, new ORM_CMN_CAL_Repetition.Query() { CMN_CAL_RepetitionID = eventItem.Repetition_RefID, Tenant_RefID = securityTicket.TenantID, IsDeleted = false }).Single(); ORM_CMN_CAL_RepetitionPatterns_Weekly weekly = ORM_CMN_CAL_RepetitionPatterns_Weekly.Query.Search(Connection, Transaction, new ORM_CMN_CAL_RepetitionPatterns_Weekly.Query() { Repetition_RefID = repetition.CMN_CAL_RepetitionID, Tenant_RefID = securityTicket.TenantID, IsDeleted = false }).Single(); assignemnt.IsDeleted = true; assignemnt.Save(Connection, Transaction); ORM_CMN_CAL_AVA_Availability.IsDeleted = true; ORM_CMN_CAL_AVA_Availability.Save(Connection, Transaction); date.IsDeleted = true; date.Save(Connection, Transaction); eventItem.IsDeleted = true; eventItem.Save(Connection, Transaction); repetition.IsDeleted = true; repetition.Save(Connection, Transaction); weekly.IsDeleted = true; weekly.Save(Connection, Transaction); } } } return(returnValue); #endregion UserCode }
protected static FR_Guid Execute(DbConnection Connection, DbTransaction Transaction, P_L5OU_SPUOH_1111 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null) { #region UserCode var returnValue = new FR_Guid(); foreach (var item in Parameter.OpeningHours) { #region Non-working Hours if (item.IsNonWorkingHours) { var workTimeExceptionsQuery = new ORM_CMN_STR_Office_WorktimeTemplateException.Query(); workTimeExceptionsQuery.IsDeleted = false; workTimeExceptionsQuery.Tenant_RefID = securityTicket.TenantID; workTimeExceptionsQuery.Office_RefID = Parameter.OfficeID; workTimeExceptionsQuery.CMN_STR_Office_WorktimeTemplateExceptionID = item.TimeID; var workTimeExceptions = ORM_CMN_STR_Office_WorktimeTemplateException.Query.Search(Connection, Transaction, workTimeExceptionsQuery).SingleOrDefault(); #region Delete if (item.IsDeleted) { if (workTimeExceptions != null) { workTimeExceptions.IsDeleted = true; workTimeExceptions.Save(Connection, Transaction); } } #endregion else { #region Save if (workTimeExceptions == null) { workTimeExceptions = new ORM_CMN_STR_Office_WorktimeTemplateException(); workTimeExceptions.CMN_STR_Office_WorktimeTemplateExceptionID = item.TimeID; workTimeExceptions.CMN_CAL_Event_RefID = Guid.NewGuid(); workTimeExceptions.Office_RefID = Parameter.OfficeID; workTimeExceptions.Description = item.Description; workTimeExceptions.Tenant_RefID = securityTicket.TenantID; workTimeExceptions.Creation_Timestamp = DateTime.Now; workTimeExceptions.Save(Connection, Transaction); var Events = new ORM_CMN_CAL_Event(); Events.CMN_CAL_EventID = workTimeExceptions.CMN_CAL_Event_RefID; Events.IsRepetitive = item.IsRepetitive; Events.IsWholeDayEvent = item.IsWholeDay; Events.StartTime = item.StartDate; Events.EndTime = item.EndDate; Events.Tenant_RefID = securityTicket.TenantID; Events.Creation_Timestamp = DateTime.Now; if (item.IsRepetitive) { Events.Repetition_RefID = Guid.NewGuid(); var repetitions = new ORM_CMN_CAL_Repetition(); repetitions.CMN_CAL_RepetitionID = Events.Repetition_RefID; repetitions.IsMonthly = item.IsMontly; repetitions.IsWeekly = item.IsWeekly; repetitions.IsDaily = item.IsDaily; repetitions.IsYearly = item.IsYearly; repetitions.Tenant_RefID = securityTicket.TenantID; repetitions.Creation_Timestamp = DateTime.Now; repetitions.Save(Connection, Transaction); if (item.IsWeekly) { var repetitionWeekly = new ORM_CMN_CAL_RepetitionPatterns_Weekly(); repetitionWeekly.CMN_CAL_RepetitionPattern_WeeklyID = Guid.NewGuid(); repetitionWeekly.Repetition_RefID = repetitions.CMN_CAL_RepetitionID; repetitionWeekly.Tenant_RefID = securityTicket.TenantID; repetitionWeekly.Creation_Timestamp = DateTime.Now; repetitionWeekly.Save(Connection, Transaction); } if (item.IsMontly) { var repetitionMontly = new ORM_CMN_CAL_RepetitionPatterns_Monthly(); repetitionMontly.CMN_CAL_RepetitionPattern_MonthlyID = Guid.NewGuid(); repetitionMontly.Repetition_RefID = repetitions.CMN_CAL_RepetitionID; repetitionMontly.Tenant_RefID = securityTicket.TenantID; repetitionMontly.Creation_Timestamp = DateTime.Now; repetitionMontly.Save(Connection, Transaction); } if (item.IsDaily) { var repetitionDaily = new ORM_CMN_CAL_RepetitionPatterns_Daily(); repetitionDaily.CMN_CAL_RepetitionPattern_DailyID = Guid.NewGuid(); repetitionDaily.Repetition_RefID = repetitions.CMN_CAL_RepetitionID; repetitionDaily.Tenant_RefID = securityTicket.TenantID; repetitionDaily.Creation_Timestamp = DateTime.Now; repetitionDaily.Save(Connection, Transaction); } if (item.IsYearly) { var repetitionYearly = new ORM_CMN_CAL_RepetitionPatterns_Yearly(); repetitionYearly.CMN_CAL_RepetitionPattern_YearlyID = Guid.NewGuid(); repetitionYearly.Repetition_RefID = repetitions.CMN_CAL_RepetitionID; repetitionYearly.Tenant_RefID = securityTicket.TenantID; repetitionYearly.Creation_Timestamp = DateTime.Now; repetitionYearly.Save(Connection, Transaction); } } Events.Save(Connection, Transaction); } #endregion #region Edit else { workTimeExceptions.Description = item.Description; workTimeExceptions.Save(Connection, Transaction); var EventsQuery = new ORM_CMN_CAL_Event.Query(); EventsQuery.CMN_CAL_EventID = workTimeExceptions.CMN_CAL_Event_RefID; EventsQuery.IsDeleted = false; EventsQuery.Tenant_RefID = securityTicket.TenantID; var Events = ORM_CMN_CAL_Event.Query.Search(Connection, Transaction, EventsQuery).Single(); Events.IsRepetitive = item.IsRepetitive; Events.IsWholeDayEvent = item.IsWholeDay; Events.StartTime = item.StartDate; Events.EndTime = item.EndDate; #region delete old repetation if exists var repetitionsQuery = new ORM_CMN_CAL_Repetition.Query(); repetitionsQuery.IsDeleted = false; repetitionsQuery.Tenant_RefID = securityTicket.TenantID; repetitionsQuery.CMN_CAL_RepetitionID = Events.Repetition_RefID; var repetitions = ORM_CMN_CAL_Repetition.Query.Search(Connection, Transaction, repetitionsQuery).SingleOrDefault(); if (repetitions != null) { repetitions.IsDeleted = true; repetitions.Save(Connection, Transaction); if (repetitions.IsDaily) { var repetitionDailyQuery = new ORM_CMN_CAL_RepetitionPatterns_Daily.Query(); repetitionDailyQuery.IsDeleted = false; repetitionDailyQuery.Tenant_RefID = securityTicket.TenantID; repetitionDailyQuery.Repetition_RefID = repetitions.CMN_CAL_RepetitionID; var repetitionDaily = ORM_CMN_CAL_RepetitionPatterns_Daily.Query.Search(Connection, Transaction, repetitionDailyQuery).Single(); repetitionDaily.IsDeleted = true; repetitionDaily.Save(Connection, Transaction); } if (repetitions.IsWeekly) { var repetitionWeeklyQuery = new ORM_CMN_CAL_RepetitionPatterns_Weekly.Query(); repetitionWeeklyQuery.IsDeleted = false; repetitionWeeklyQuery.Tenant_RefID = securityTicket.TenantID; repetitionWeeklyQuery.Repetition_RefID = repetitions.CMN_CAL_RepetitionID; var repetitionWeekly = ORM_CMN_CAL_RepetitionPatterns_Weekly.Query.Search(Connection, Transaction, repetitionWeeklyQuery).Single(); repetitionWeekly.IsDeleted = true; repetitionWeekly.Save(Connection, Transaction); } if (repetitions.IsMonthly) { var repetitionMontlyQuery = new ORM_CMN_CAL_RepetitionPatterns_Monthly.Query(); repetitionMontlyQuery.IsDeleted = false; repetitionMontlyQuery.Tenant_RefID = securityTicket.TenantID; repetitionMontlyQuery.Repetition_RefID = repetitions.CMN_CAL_RepetitionID; var repetitionMontly = ORM_CMN_CAL_RepetitionPatterns_Monthly.Query.Search(Connection, Transaction, repetitionMontlyQuery).Single(); repetitionMontly.IsDeleted = true; repetitionMontly.Save(Connection, Transaction); } if (repetitions.IsYearly) { var repetitionYearlyQuery = new ORM_CMN_CAL_RepetitionPatterns_Yearly.Query(); repetitionYearlyQuery.IsDeleted = false; repetitionYearlyQuery.Tenant_RefID = securityTicket.TenantID; repetitionYearlyQuery.Repetition_RefID = repetitions.CMN_CAL_RepetitionID; var repetitionYearly = ORM_CMN_CAL_RepetitionPatterns_Yearly.Query.Search(Connection, Transaction, repetitionYearlyQuery).Single(); repetitionYearly.IsDeleted = true; repetitionYearly.Save(Connection, Transaction); } } #endregion if (item.IsRepetitive) { Events.Repetition_RefID = Guid.NewGuid(); repetitions = new ORM_CMN_CAL_Repetition(); repetitions.CMN_CAL_RepetitionID = Events.Repetition_RefID; repetitions.IsMonthly = item.IsMontly; repetitions.IsWeekly = item.IsWeekly; repetitions.IsDaily = item.IsDaily; repetitions.IsYearly = item.IsYearly; repetitions.Tenant_RefID = securityTicket.TenantID; repetitions.Creation_Timestamp = DateTime.Now; repetitions.Save(Connection, Transaction); if (item.IsWeekly) { var repetitionWeekly = new ORM_CMN_CAL_RepetitionPatterns_Weekly(); repetitionWeekly.CMN_CAL_RepetitionPattern_WeeklyID = Guid.NewGuid(); repetitionWeekly.Repetition_RefID = repetitions.CMN_CAL_RepetitionID; repetitionWeekly.Tenant_RefID = securityTicket.TenantID; repetitionWeekly.Creation_Timestamp = DateTime.Now; repetitionWeekly.Save(Connection, Transaction); } if (item.IsMontly) { var repetitionMontly = new ORM_CMN_CAL_RepetitionPatterns_Monthly(); repetitionMontly.CMN_CAL_RepetitionPattern_MonthlyID = Guid.NewGuid(); repetitionMontly.Repetition_RefID = repetitions.CMN_CAL_RepetitionID; repetitionMontly.Tenant_RefID = securityTicket.TenantID; repetitionMontly.Creation_Timestamp = DateTime.Now; repetitionMontly.Save(Connection, Transaction); } if (item.IsDaily) { var repetitionDaily = new ORM_CMN_CAL_RepetitionPatterns_Daily(); repetitionDaily.CMN_CAL_RepetitionPattern_DailyID = Guid.NewGuid(); repetitionDaily.Repetition_RefID = repetitions.CMN_CAL_RepetitionID; repetitionDaily.Tenant_RefID = securityTicket.TenantID; repetitionDaily.Creation_Timestamp = DateTime.Now; repetitionDaily.Save(Connection, Transaction); } if (item.IsYearly) { var repetitionYearly = new ORM_CMN_CAL_RepetitionPatterns_Yearly(); repetitionYearly.CMN_CAL_RepetitionPattern_YearlyID = Guid.NewGuid(); repetitionYearly.Repetition_RefID = repetitions.CMN_CAL_RepetitionID; repetitionYearly.Tenant_RefID = securityTicket.TenantID; repetitionYearly.Creation_Timestamp = DateTime.Now; repetitionYearly.Save(Connection, Transaction); } } Events.Save(Connection, Transaction); } #endregion } } #endregion #region Standard Hours else { var workTimeTemplateQuery = new ORM_CMN_STR_Office_Weekly_WorkTimeTemplate.Query(); workTimeTemplateQuery.IsDeleted = false; workTimeTemplateQuery.Office_RefID = Parameter.OfficeID; workTimeTemplateQuery.CMN_STR_Office_Weekly_WorkTimeTemplateID = item.TimeID; workTimeTemplateQuery.Tenant_RefID = securityTicket.TenantID; var workTimeTemplate = ORM_CMN_STR_Office_Weekly_WorkTimeTemplate.Query.Search(Connection, Transaction, workTimeTemplateQuery).SingleOrDefault(); #region Delete if (item.IsDeleted) { if (workTimeTemplate != null) { workTimeTemplate.IsDeleted = true; workTimeTemplate.Save(Connection, Transaction); } } #endregion else { #region Save if (workTimeTemplate == null) { workTimeTemplate = new ORM_CMN_STR_Office_Weekly_WorkTimeTemplate(); workTimeTemplate.CMN_STR_Office_Weekly_WorkTimeTemplateID = item.TimeID; workTimeTemplate.Office_RefID = Parameter.OfficeID; workTimeTemplate.CMN_CAL_WeeklyOfficeHours_Interval_RefID = Guid.NewGuid(); workTimeTemplate.Tenant_RefID = securityTicket.TenantID; workTimeTemplate.Creation_Timestamp = DateTime.Now; workTimeTemplate.Save(Connection, Transaction); ORM_CMN_CAL_WeeklyOfficeHours_Interval WeeklyOfficeHours_Interval = new ORM_CMN_CAL_WeeklyOfficeHours_Interval(); WeeklyOfficeHours_Interval.CMN_CAL_WeeklyOfficeHours_IntervalID = workTimeTemplate.CMN_CAL_WeeklyOfficeHours_Interval_RefID; WeeklyOfficeHours_Interval.WeeklyOfficeHours_Template_RefID = Guid.NewGuid(); WeeklyOfficeHours_Interval.Tenant_RefID = securityTicket.TenantID; WeeklyOfficeHours_Interval.Creation_Timestamp = DateTime.Now; WeeklyOfficeHours_Interval.IsMonday = item.IsMonday; WeeklyOfficeHours_Interval.IsTuesday = item.IsTuesday; WeeklyOfficeHours_Interval.IsWednesday = item.IsWednesday; WeeklyOfficeHours_Interval.IsThursday = item.IsThursday; WeeklyOfficeHours_Interval.IsFriday = item.IsFriday; WeeklyOfficeHours_Interval.IsSaturday = item.IsSaturday; WeeklyOfficeHours_Interval.IsSunday = item.IsSunday; WeeklyOfficeHours_Interval.IsWholeDay = item.IsWholeDay; WeeklyOfficeHours_Interval.TimeFrom_InMinutes = item.TimeFrom_InMinutes; WeeklyOfficeHours_Interval.TimeTo_InMinutes = item.TimeTo_InMinutes; WeeklyOfficeHours_Interval.Save(Connection, Transaction); ORM_CMN_CAL_WeeklyOfficeHours_Template WeeklyOfficeHours_Template = new ORM_CMN_CAL_WeeklyOfficeHours_Template(); WeeklyOfficeHours_Template.CMN_CAL_WeeklyOfficeHours_TemplateID = WeeklyOfficeHours_Interval.WeeklyOfficeHours_Template_RefID; WeeklyOfficeHours_Template.OfficeHoursTemplate_Name = item.OfficeHoursTemplate_Name; WeeklyOfficeHours_Template.Creation_Timestamp = DateTime.Now; WeeklyOfficeHours_Template.Tenant_RefID = securityTicket.TenantID; WeeklyOfficeHours_Template.Save(Connection, Transaction); } else #endregion #region Edit { var WeeklyOfficeHours_IntervalQuery = new ORM_CMN_CAL_WeeklyOfficeHours_Interval.Query(); WeeklyOfficeHours_IntervalQuery.IsDeleted = false; WeeklyOfficeHours_IntervalQuery.Tenant_RefID = securityTicket.TenantID; WeeklyOfficeHours_IntervalQuery.CMN_CAL_WeeklyOfficeHours_IntervalID = workTimeTemplate.CMN_CAL_WeeklyOfficeHours_Interval_RefID; var WeeklyOfficeHours_Interval = ORM_CMN_CAL_WeeklyOfficeHours_Interval.Query.Search(Connection, Transaction, WeeklyOfficeHours_IntervalQuery).Single(); WeeklyOfficeHours_Interval.IsWholeDay = item.IsWholeDay; WeeklyOfficeHours_Interval.TimeFrom_InMinutes = item.TimeFrom_InMinutes; WeeklyOfficeHours_Interval.TimeTo_InMinutes = item.TimeTo_InMinutes; WeeklyOfficeHours_Interval.Save(Connection, Transaction); var WeeklyOfficeHours_TemplateQuery = new ORM_CMN_CAL_WeeklyOfficeHours_Template.Query(); WeeklyOfficeHours_TemplateQuery.IsDeleted = false; WeeklyOfficeHours_TemplateQuery.Tenant_RefID = securityTicket.TenantID; WeeklyOfficeHours_TemplateQuery.CMN_CAL_WeeklyOfficeHours_TemplateID = WeeklyOfficeHours_Interval.WeeklyOfficeHours_Template_RefID; var WeeklyOfficeHours_Template = ORM_CMN_CAL_WeeklyOfficeHours_Template.Query.Search(Connection, Transaction, WeeklyOfficeHours_TemplateQuery).Single(); WeeklyOfficeHours_Template.OfficeHoursTemplate_Name = item.OfficeHoursTemplate_Name; WeeklyOfficeHours_Template.Save(Connection, Transaction); } #endregion } } #endregion } if (Parameter.UpdateSlots) { cls_CreateUpdate_Slots_for_Practice.Invoke(Connection, Transaction, new P_L5S_SUSfP_1708() { PracticeID = Parameter.OfficeID }, securityTicket); } return(returnValue); #endregion UserCode }