コード例 #1
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,Titulo,FechaEdicion,AutorId")] Biografia biografia)
        {
            if (id != biografia.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(biografia);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!BiografiaExists(biografia.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["AutorId"] = new SelectList(_context.Autor, "Id", "Id", biografia.AutorId);
            return(View(biografia));
        }
コード例 #2
0
ファイル: FrmTester.cs プロジェクト: Silvia-Rus/Parciales_2
 private void Form1_Load(object sender, EventArgs e)
 {
     Biografia p1 = (Biografia)"Life (Keith Richards)";
     Biografia p2 = new Biografia("White line fever (Lemmy)", 5);
     Biografia p3 = new Biografia("Commando (Johnny Ramone)", 2, 5000);
     Comic     p4 = new Comic("La Muerte de Superman (Superman)", true, 1, 1850);
     Comic     p5 = new Comic("Año Uno (Batman)", false, 3, 1270);
 }
コード例 #3
0
        public async Task <IActionResult> Create([Bind("Id,Titulo,FechaEdicion,AutorId")] Biografia biografia)
        {
            if (ModelState.IsValid)
            {
                _context.Add(biografia);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["AutorId"] = new SelectList(_context.Autor, "Id", "Id", biografia.AutorId);
            return(View(biografia));
        }
コード例 #4
0
        private void FrmTest_Load(object sender, EventArgs e)
        {
            Biografia p1 = (Biografia)"Life (Keith Richards)";
            Biografia p2 = new Biografia("White line fever (Lemmy)", 5);
            Biografia p3 = new Biografia("Commando (Johnny Ramone)", 2, 5000);
            Comic     p4 = new Comic("La Muerte de Superman (Superman)", true, 1, 1850);
            Comic     p5 = new Comic("Año Uno (Batman)", false, 3, 1270);

            this.lstStock.Items.Add(p1);//p1.ToString()
            this.lstStock.Items.Add(p2);
            this.lstStock.Items.Add(p3);
            this.lstStock.Items.Add(p4);
            this.lstStock.Items.Add(p5);
        }
コード例 #5
0
        /// <summary>
        /// Hardcodea informacion al abrir el formulario.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void FrmTest_Load(object sender, EventArgs e)
        {
            // Instanciar objetos para el listBox
            Biografia p1 = (Biografia)"Life (Keith Richards)";
            Biografia p2 = new Biografia("White line fever (Lemmy)", 5);
            Biografia p3 = new Biografia("Commando (Johnny Ramone)", 2, 5000);
            Comic     p4 = new Comic("La Muerte de Superman (Superman)", true, 1, 1850);
            Comic     p5 = new Comic("Año Uno (Batman)", false, 3, 1270);

            // Agrego al listBox
            lstStock.Items.Add(p1);
            lstStock.Items.Add(p2);
            lstStock.Items.Add(p3);
            lstStock.Items.Add(p4);
            lstStock.Items.Add(p5);

            // Cargo ventas para testear el richText
            //bool pudo = elTipoDelComic + p1;
            //pudo = elTipoDelComic + p2;
            //pudo = elTipoDelComic + p3;
            //pudo = elTipoDelComic + p4;
            //pudo = elTipoDelComic + p5;
        }
コード例 #6
0
        public async Task <IResult <Biografia> > GetBiografiaArtista(string artId)
        {
            try
            {
                var url  = string.Format(VagalumeApiConstants.ARTISTA_BIOGRAFIA_URL, artId);
                var html = await ProviderHelper.GetDefaultHtmlText(url, _httpRequestProcessor);

                var htmlDoc = new HtmlDocument();
                htmlDoc.LoadHtml(html);

                var htmlBody = htmlDoc.GetElementbyId("body");

                HtmlNode textCol = htmlBody.Descendants("div").Where(c => c.GetAttributeValue("class", "").Equals("textCol")).FirstOrDefault();

                HtmlNode bioTitleBox    = htmlBody.Descendants("div").Where(c => c.GetAttributeValue("class", "").Equals("bioTitleBox")).FirstOrDefault();
                HtmlNode bioTextBox     = htmlBody.Descendants("div").Where(c => c.GetAttributeValue("class", "").Equals("bioTextBox")).FirstOrDefault();
                HtmlNode bioInfoWrapper = htmlBody.Descendants("div").Where(c => c.GetAttributeValue("class", "").Equals("bioInfoWrapper")).FirstOrDefault();

                var name        = bioTitleBox.ChildNodes.Where(c => c.Name == "h4").FirstOrDefault()?.InnerText?.Trim();
                var born        = bioTitleBox.ChildNodes.Where(c => c.Name == "p").FirstOrDefault()?.InnerText?.Trim();
                var country     = bioTitleBox.ChildNodes.Where(c => c.Name == "p").LastOrDefault()?.InnerText?.Trim();
                var bio         = bioTextBox.ChildNodes.Where(c => c.Name == "p").FirstOrDefault()?.InnerText?.Trim().Replace("<br>", "\n").Replace("<br />", "\n");
                var siteOficial = bioInfoWrapper.Descendants("a").Where(c => c.GetAttributeValue("class", "").Equals("external-after")).FirstOrDefault()?
                                  .Attributes.Where(attr => attr.Name == "href").FirstOrDefault()?.Value?.Trim();

                List <string> socialList   = new List <string>();
                var           ulSocialList = bioInfoWrapper.Descendants("ul").Where(c => c.GetAttributeValue("class", "").Equals("social-list")).FirstOrDefault();
                foreach (var li in ulSocialList.ChildNodes)
                {
                    var link = li.ChildNodes.Where(c => c.Name == "a").FirstOrDefault()?.Attributes.Where(attr => attr.Name == "href").FirstOrDefault()?.Value?.Trim();
                    socialList.Add(link);
                }

                List <FasSite> fasSitesList  = new List <FasSite>();
                var            aElemFasSites = bioInfoWrapper.Descendants("a").Where(c => c.GetAttributeValue("class", "").Equals("external-before")).ToList();
                foreach (var a in aElemFasSites)
                {
                    var     link     = a.Attributes.Where(c => c.Name == "href").FirstOrDefault()?.Value?.Trim();
                    var     namesite = a.InnerText?.Trim();
                    FasSite fasSite  = new FasSite()
                    {
                        Name = namesite, Url = link
                    };
                    fasSitesList.Add(fasSite);
                }

                Biografia result = new Biografia()
                {
                    Art          = artId,
                    Name         = name,
                    Born         = born,
                    Country      = country,
                    Bio          = bio,
                    SiteOficial  = siteOficial,
                    RedesSociais = socialList.ToArray(),
                    FasSites     = fasSitesList
                };

                return(Result.Success(result));
            }
            catch (Exception ex)
            {
                return(Result.Fail <Biografia>(ex.Message));
            }
        }