Esempio n. 1
0
        internal static IEnumerable <CourseHeaderWithPrice> GetCourseHeadersWithPrices(CourseHeader_Filter[] filter, ApiManagerCredentials credentials, int size)
        {
            var list = new List <CourseHeaderWithPrice>();

            try
            {
                var courseHeaders = CourseService.GetCourseHeaders(filter, credentials, size);
                if (courseHeaders != null && courseHeaders.Any())
                {
                    List <CoursePrices> coursePrices = null;

                    var courseTypes = courseHeaders.Select(x => x.Course_Type_No).Distinct();
                    if (courseTypes != null && courseTypes.Any())
                    {
                        var criteria = string.Join("|", courseTypes);
                        if (!string.IsNullOrEmpty(criteria))
                        {
                            if (criteria.StartsWith("|"))
                            {
                                criteria = criteria.Substring(1);
                            }
                            if (criteria.EndsWith("|"))
                            {
                                criteria = criteria.Remove(criteria.Length - 1);
                            }
                            coursePrices = CourseService.GetCoursePricesByType(credentials.SubscriptionKey, credentials.AccountKey, criteria).ToList();
                        }
                    }

                    if (coursePrices == null)
                    {
                        coursePrices = new List <CoursePrices>();
                    }

                    foreach (var couseHeader in courseHeaders.Where(x => x != null).ToList())
                    {
                        var prices = coursePrices.Any() ? coursePrices.Where(x => x.CourseType.Equals(couseHeader.Course_Type_No)) : new List <CoursePrices>();
                        list.Add(new CourseHeaderWithPrice(couseHeader, prices));
                    }
                }
            }
            catch (Exception exception)
            {
                Services.LogService.Error("Fejl i sammensætning af kurser og priser.", exception);
            }

            return(list);
        }
Esempio n. 2
0
        internal static CourseHeaderWithPrice GetCourseHeaderWithPrices(string courseNumber, ApiManagerCredentials credentials)
        {
            try
            {
                var courseHeaderWithPrices = new CourseHeaderWithPrice();
                var courseHeader           = CourseService.GetCourseHeader(courseNumber, credentials);
                if (courseHeader != null)
                {
                    courseHeaderWithPrices.Info   = courseHeader;
                    courseHeaderWithPrices.Prices = CourseService.GetCoursePricesByType(credentials.SubscriptionKey, credentials.AccountKey, courseHeader.Course_Type_No);
                }

                return(courseHeaderWithPrices);
            }
            catch (Exception exception)
            {
                Services.LogService.Error("Fejl i sammensætning af kursus og priser.", exception);
                return(null);
            }
        }