public async Task <IEnumerable <dynamic> > SaveOrUpdate([FromBody] ScheduleSetupViewModel sv)
        {
            string sql = "dbo.EAppSaveScheduleSetup";

            using (var conn = util.MasterCon())
            {
                try
                {
                    string ScheduleEquipmentsJson = null;
                    string ScheduleServicesJson   = null;
                    if (sv.ScheduleEquipments != null && sv.ScheduleEquipments.Count > 0)
                    {
                        string Header = "{\"ScheduleEquipments\": ";
                        string Footer = "}";
                        ScheduleEquipmentsJson = Header + JsonConvert.SerializeObject(sv.ScheduleEquipments) + Footer;
                    }

                    if (sv.ScheduleServices != null && sv.ScheduleServices.Count > 0)
                    {
                        string Header = "{\"ScheduleServices\": ";
                        string Footer = "}";
                        ScheduleServicesJson = Header + JsonConvert.SerializeObject(sv.ScheduleServices) + Footer;
                    }

                    return(await(conn.QueryAsync <dynamic>(sql, new
                    {
                        sv.ScheduleSetupId,
                        sv.ClientSiteId,
                        sv.ScheduleName,
                        sv.StartDate,
                        sv.EndDate,
                        sv.IntervalDays,
                        sv.EstJobDays,
                        ScheduleEquipmentsJson,
                        ScheduleServicesJson,
                        sv.StatusId,
                        sv.UserId,
                        //sv.ProgramTypeId
                    }, commandType: CommandType.StoredProcedure)));
                }
                catch (SqlException sqlException)
                {
                    if (sqlException.Number == 2601 || sqlException.Number == 2627)
                    {
                        throw new CustomException("Duplicate", "Schedule Name already Exists.", "Error", true, sqlException);
                    }
                    else
                    {
                        throw new CustomException("Due to some Technical Reason, Unable to Save or Update", "Error", true, sqlException);
                    }
                }
                catch (Exception ex)
                {
                    throw new CustomException("Unable to Save Or Update, Please Contact Support!!!", "Error", true, ex);
                }
            }
        }
        public async Task <IActionResult> Update([FromBody] ScheduleSetupViewModel scv)
        {
            try
            {
                CurrentUser cUser = new CurrentUser(HttpContext, _configuration);
                scv.UserId = cUser.UserId;
                var result = await scheduleRepo.SaveOrUpdate(scv);

                await auditLogService.LogActivity(cUser.UserId, cUser.HostIP, cUser.SessionId, "Schedule", "Schedule Modified.");

                return(Ok(result));
            }
            catch (CustomException cex)
            {
                var returnObj = new EmaintenanceMessage(cex.Message, cex.Type, cex.IsException, cex.Exception?.ToString());
                return(StatusCode(StatusCodes.Status500InternalServerError, returnObj));
            }
            catch (Exception ex)
            {
                return(StatusCode(StatusCodes.Status500InternalServerError, new EmaintenanceMessage(ex.Message)));
            }
        }