public async Task <IActionResult> GetAllSchedules() { try { _logger.LogInformation(string.Format(Constants.GetScheduleRequestReceived, Guid.Parse(RouteData.Values["FacilityKey"].ToString()))); var schedules = await _scheduleBusiness.GetSchedules(Guid.Parse(RouteData.Values["FacilityKey"].ToString())); if (schedules.Any()) { return(Ok(schedules)); } _logger.LogError(Constants.Empty_List); return(NotFound()); } catch (Exception ex) { _logger.LogError(ex.Message); return(StatusCode(500)); } }
/// <summary> /// to get all routing rule from database.. /// </summary> /// <param name="facilityID"></param> /// <param name="page"></param> /// <param name="pageSize"></param> /// <param name="searchString"></param> /// <returns></returns> public IEnumerable <RoutingRulesResult> GetAllRoutingRule(int page = 0, int pageSize = 0, string searchString = "") { var facilityID = Utility.ParseStringToGuid(_executionContextAccessor.Current.Facility.FacilityKey); IEnumerable <Schedule.Models.ScheduleResponse> schedule = _scheduleBusiness.GetSchedules(facilityID).GetAwaiter().GetResult(); IEnumerable <RoutingRule> rule = _routingRulesRepository.GetRoutingRules(facilityID, page, pageSize, searchString).GetAwaiter().GetResult(); var result = new List <RoutingRulesResult>(); foreach (var item in rule) { var sheduleIdByRule = item.RoutingRuleScheduleTiming.Select(x => x).ToList(); // TO DO Destination // To Do TransactionPriority var perRuleShedule = (from s in schedule join rs in sheduleIdByRule on s.Key equals rs.ScheduleTimingKey select $"{s.Name},{String.Join(",", s.ScheduleDays.Select(w => w).ToArray())},{s.StartTime},{s.EndTime};" ).ToList(); //var perTraPri = (from s in item.RoutingRuleTranPriority TO DO // select // $"{s.TranPriorityKeyNavigation.PriorityCode}" // ).ToList(); result.Add(new RoutingRulesResult { RoutingRuleName = item.RoutingRuleName, RoutingRuleKey = item.RoutingRuleKey, Schedules = String.Join(",", perRuleShedule.Select(w => w).ToArray()), TranPriorities = "",//String.Join(",", perTraPri.Select(w => w).ToArray()) , Destinations = "" }); } return(result); }