// GET: CourseContent
        public async Task <ActionResult> Index(int id)
        {
            var studentId = Request.IsAuthenticated ? HttpContext.GetUserId() : null;
            var sections  = await SectionExtensions.GetCourseSectionAsync(id, studentId);

            return(View(sections));
        }
Example #2
0
        /// <summary>
        /// Get all medals on the game
        /// </summary>
        public IEnumerable <Medal> GetMedals(Platform platform)
        {
            Log.DebugFormat("Fetching medals on platform {0}...", platform);
            string server;

            switch (platform)
            {
            case Platform.XBOX:
                server = "api-xbox-console.worldoftanks.com";
                break;

            case Platform.PS:
                server = "api-ps4-console.worldoftanks.com";
                break;

            default:
                throw new ArgumentOutOfRangeException(nameof(platform), platform, null);
            }

            var url  = $"https://{server}/wotx/encyclopedia/achievements/?application_id={ApplicationId}";
            var json = GetContentSync($"Achievements.{platform}.json", url, WebCacheAge, false, Encoding.UTF8).Content;

            var o = JObject.Parse(json);

            var status = (string)o["status"];

            if (status != "ok")
            {
                var error = o["error"];
                Log.Error($"Error: {(string)error["code"]} - {(string)error["message"]}");
                throw new ApplicationException($"Error calling WG API: {(string)error["code"]} - {(string)error["message"]}");
            }

            var medals = new List <Medal>();

            var data = o["data"];

            foreach (var t in data.Cast <JProperty>())
            {
                var ti = t.Value;

                var medal = new Medal
                {
                    Platform        = platform,
                    Code            = t.Name,
                    Category        = CategoryExtensions.Parse((string)ti["category"]),
                    Name            = (string)ti["name"],
                    Section         = SectionExtensions.Parse((string)ti["section"]),
                    Type            = TypeExtensions.Parse((string)ti["type"]),
                    Description     = (string)ti["description"],
                    HeroInformation = (string)ti["hero_info"],
                    Condition       = (string)ti["condition"]
                };

                medals.Add(medal);
            }

            return(medals);
        }
Example #3
0
        // GET: ProductContent
        public async Task <ActionResult> Index(int id)
        {
            var userId   = Request.IsAuthenticated ? HttpContext.GetUserId() : null;
            var sections = await SectionExtensions.GetProductSectionsAsync(id, userId);

            var downloads = await SectionExtensions.GetProductDownloadSectionsAsync(id, userId);

            sections.Sections.Add(downloads);

            return(View(sections));
        }
        public async Task <ActionResult> Content(int?productId, int?itemId)
        {
            if (productId == null || itemId == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }

            var model = await SectionExtensions.GetContentAsync(productId.Value, itemId.Value);

            return(View(model));
        }
        // GET: ProductModel
        public async Task <ActionResult> Index(int?id)
        {
            if (!id.HasValue)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }

            var userId   = Request.IsAuthenticated ? User.Identity.GetUserId() : null;
            var sections = await SectionExtensions.GetProductSectionAsync(id.Value, userId);

            return(View(sections));
        }
Example #6
0
        public async Task <ActionResult> Index(int id)
        {
            var model = new CourseSectionModel
            {
                Title    = "The Title",
                Sections = new List <CourseSection>()
            };
            var userId   = Request.IsAuthenticated ? HttpContext.GetUserId() : null;
            var sections = await SectionExtensions.GetCourseSectionsAsync(id, userId);

            return(View(model));
        }
        /// <summary>
        /// Creates an XML string containing an unmerged view of the <see cref="T:System.Configuration.ConfigurationSection"/> object as a single section to write to a file.
        /// </summary>
        /// <returns>
        /// An XML string containing an unmerged view of the <see cref="T:System.Configuration.ConfigurationSection"/> object.
        /// </returns>
        /// <param name="parentElement">The <see cref="T:System.Configuration.ConfigurationElement"/> instance to use as the parent when performing the un-merge.
        ///                 </param><param name="name">The name of the section to create.
        ///                 </param><param name="saveMode">The <see cref="T:System.Configuration.ConfigurationSaveMode"/> instance to use when writing to a string.
        ///                 </param>
        protected override string SerializeSection(ConfigurationElement parentElement, string name, ConfigurationSaveMode saveMode)
        {
            ExtensionElementMap.Clear();
            currentSection = this;
            TypeResolver.SetAliases(this);
            InitializeSectionExtensions();

            var sb = new StringBuilder();

            using (var writer = MakeXmlWriter(sb))
            {
                writer.WriteStartElement(name, XmlNamespace);
                writer.WriteAttributeString("xmlns", XmlNamespace);
                TypeAliases.SerializeElementContents(writer, "alias");
                Namespaces.SerializeElementContents(writer, "namespace");
                Assemblies.SerializeElementContents(writer, "assembly");
                SectionExtensions.SerializeElementContents(writer, "sectionExtension");
                Containers.SerializeElementContents(writer, "container");
                writer.WriteEndElement();
            }

            return(sb.ToString());
        }
Example #8
0
        public async Task <ActionResult> Content(int productId, int itemId)
        {
            var model = await SectionExtensions.GetContentAsync(productId, itemId);

            return(View("Content", model));
        }
Example #9
0
 public void TestGetLastTableNullSection()
 {
     Assert.Throws <ArgumentNullException>(() => SectionExtensions.GetLastTable(null));
 }