Esempio n. 1
0
        public void GetBusinessInfo()
        {
            string url = "http://www.imdb.com/title/@/business?ref_=ttco_ql_4";

            url = url.Replace("@", nameUrl);
            string htmlPage = WebAO.CodeHtml(url);

            string[] pageLines = htmlPage.Split('\n');

            EnglishName = "";
            int i = 0;

            for (i = 0; i < pageLines.Length; i++)
            {
                string line = pageLines[i].Trim();
                if (line.Contains("Budget"))
                {
                    line = pageLines[++i].Trim();

                    Budget = (line.Substring(1, line.IndexOf(" ("))).Replace(",", "");
                    Budget = Budget.Trim();
                }

                if (line.Contains("<span class=\"title-extra\""))
                {
                    //Pode ser que o nome nacional seja igual ao nome original
                    int indexItalic = line.IndexOf("<i>(or");
                    if (indexItalic != -1)
                    {
                        int jump = line.IndexOf("<span class=\"title-extra\">") + "<span class=\"title-extra\">".Length;

                        EnglishName = line.Substring(jump, line.IndexOf("<i>(or") - (jump + 1));
                        EnglishName = EnglishName.Trim();
                    }
                }
            }
            if (EnglishName.Length == 0)
            {
                EnglishName = Name;
            }
        }
Esempio n. 2
0
 public IEnumerable <ValidationResult> Validate(ValidationContext validationContext)
 {
     //Title (must not be blank)
     if (EnglishName == null || EnglishName.Trim() == "")
     {
         yield return(new ValidationResult("English Name cannot be blank.", new[] { nameof(EnglishName) }));
     }
     else
     {
         EnglishName = EnglishName.Trim();
     }
     //Price
     if (Price == null)
     {
         yield return(new ValidationResult("Price can not be blank.", new[] { nameof(Price) }));
     }
     else if (Price < 0)
     {
         yield return(new ValidationResult("Price can not be less than 0.", new[] { nameof(Price) }));
     }
     //Player Count (must not be blank and be a number)
     if (EnglishPlayerCount == null || EnglishPlayerCount.Trim() == "")
     {
         yield return(new ValidationResult("Player Count cannot be blank.", new[] { nameof(EnglishPlayerCount) }));
     }
     else if (ModelValidations.IsStringNumeric(EnglishPlayerCount))
     {
         EnglishPlayerCount = EnglishPlayerCount.Trim();
     }
     //Category is an int, does not need to be validated.
     //Perspective Code (must not be blank)
     if (GamePerspectiveCode == null || GamePerspectiveCode.Trim() == "")
     {
         yield return(new ValidationResult("Perspective Code cannot be blank.", new[] { nameof(GamePerspectiveCode) }));
     }
     else
     {
         GamePerspectiveCode = GamePerspectiveCode.Trim();
     }
     //Status Code (must not be blank)
     if (GameFormatCode == null || GameFormatCode.Trim() == "")
     {
         yield return(new ValidationResult("Status Code cannot be blank.", new[] { nameof(GameFormatCode) }));
     }
     else
     {
         GameFormatCode = GameFormatCode.Trim();
     }
     //Subcategory is an int, does not need to be validated.
     //Description (must not be blank)
     if (EnglishDescription == null || EnglishDescription.Trim() == "")
     {
         yield return(new ValidationResult("Description cannot be blank.", new[] { nameof(EnglishDescription) }));
     }
     else
     {
         EnglishDescription = EnglishDescription.Trim();
     }
     //Status Code (must not be blank)
     if (EnglishDetail == null || EnglishDetail.Trim() == "")
     {
         yield return(new ValidationResult("Detail cannot be blank.", new[] { nameof(EnglishDetail) }));
     }
     else
     {
         EnglishDetail = EnglishDetail.Trim();
     }
     yield return(ValidationResult.Success);
 }