Пример #1
0
        public CoursePictureModel GetPicture(int companyID, int courseID)
        {
            CoursePictureModel result;

            if (IsPictureInCache(companyID, courseID))
            {
                result = GetPictureFromCache(companyID, courseID);
            }
            else
            {
                result = imageStorage.GetCoursePicture(companyID, courseID);
                if (result == null)
                {
                    throw new CourseNotFoundException();
                }

                object locker = GetOrAddConcurrentKey(companyID, courseID);
                lock (locker)
                {
                    if (!IsPictureInCache(companyID, courseID))
                    {
                        SavePictureToCache(result);
                    }
                }
            }
            return(result);
        }