public Issue ReadIssueData(string comicInfo)
        {
            var issue = new Issue();
            var XDoc = XDocument.Parse(comicInfo);

            var notes = (string)XDoc.Descendants("Notes").Where(p => p.Parent.Name.LocalName == "ComicInfo").FirstOrDefault();
            if (notes != null)
            {
                string id = GetCVIDFromNotes(notes);
                int issueId = 0;
                int.TryParse(id, out issueId);

                issue.id = issueId;
                issue.volumeId = 0; //TODO can possibly pull from db if already there using issueid - or pull from cv using series and volume
                                    //should be able to query Volume based on issue series name and volume number
                issue.name = (string)XDoc.Descendants("Title").Where(p => p.Parent.Name.LocalName == "ComicInfo").FirstOrDefault() ?? "";
                issue.issueNumber = ParseHelper.ParseInt((string)XDoc.Descendants("Number").Where(p => p.Parent.Name.LocalName == "ComicInfo").FirstOrDefault() ?? "");
                //handle issueNumberSuffix

                issue.publishMonth = ParseHelper.ParseInt((string)XDoc.Descendants("Month").Where(p => p.Parent.Name.LocalName == "ComicInfo").FirstOrDefault() ?? "");
                issue.publishYear = ParseHelper.ParseInt((string)XDoc.Descendants("Year").Where(p => p.Parent.Name.LocalName == "ComicInfo").FirstOrDefault() ?? "");
                issue.summary = (string)XDoc.Descendants("Summary").Where(p => p.Parent.Name.LocalName == "ComicInfo").FirstOrDefault() ?? "";
                issue.collected = true;
                issue.enabled = true;
            }

            return issue;
        }
 public Issue GetIssue(string ComicVineIssueRequestXMLResponse)
 {
     var issue = new Issue();
     var xDoc = XDocument.Parse(ComicVineIssueRequestXMLResponse);
     issue.id = ParseHelper.ParseInt((string)xDoc.Descendants("id").Where(p => p.Parent.Name.LocalName == "results").FirstOrDefault() ?? "0");
     var strIssueNumber = (string)xDoc.Descendants("issue_number").Where(p => p.Parent.Name.LocalName == "results").FirstOrDefault();
     issue.issueNumber = ParseHelper.ParseFloat(new String(strIssueNumber.Where(Char.IsNumber).ToArray()) ?? "");
     issue.issueNumberSuffix = new String(strIssueNumber.Where(Char.IsLetter).ToArray()) ?? "";
     issue.name = (string)xDoc.Descendants("name").Where(p => p.Parent.Name.LocalName == "results").FirstOrDefault() ?? "";
     issue.volumeId = ParseHelper.ParseInt((string)xDoc.Descendants("id").Where(p => p.Parent.Name.LocalName == "volume").FirstOrDefault() ?? "0");
     issue.summary = (string)xDoc.Descendants("deck").Where(p => p.Parent.Name.LocalName == "results").FirstOrDefault() ?? "0";
     var PublishDate = ParseHelper.ParseDateTime((string)xDoc.Descendants("cover_date").Where(p => p.Parent.Name.LocalName == "results").FirstOrDefault() ?? "");
     issue.publishMonth = PublishDate.Month;
     issue.publishYear = PublishDate.Year;
     if (issue.publishYear == 1)
     {
         issue.publishYear = 0;
         if (issue.publishMonth == 1)
         {
             issue.publishMonth = 0;
         }
     }
     issue.collected = false;
     issue.enabled = true;
     return issue;
 }
 public bool Save(Issue issue)
 {
     return repository.Save(issue);
 }
Пример #4
0
 public void CanSaveIssue()
 {
     Issue issue = new Issue
     {
         id = -7,
         name = "It's a Wonderful World",
         volumeId = -1
     };
     repository.Save(issue);
     Issue savedIssue = repository.GetIssue(-7);
     Assert.IsTrue(savedIssue.id == -7);
     Assert.IsTrue(savedIssue.name == "It's a Wonderful World");
 }
Пример #5
0
 public bool Save(Issue issue)
 {
     issues.Add(issue);
     return true;
 }
Пример #6
0
 private Issue FillIssue(DataSet ds)
 {
     Issue issue = new Issue();
     if (ds.Tables[0].Rows.Count != 0)
     {
         issue.id = ParseHelper.ParseInt(ds.Tables[0].Rows[0]["id"].ToString());
         issue.volumeId = ParseHelper.ParseInt(ds.Tables[0].Rows[0]["volume_id"].ToString());
         issue.name = ds.Tables[0].Rows[0]["name"].ToString();
         issue.issueNumber = ParseHelper.ParseFloat(ds.Tables[0].Rows[0]["issue_number"].ToString());
         issue.publishMonth = ParseHelper.ParseInt(ds.Tables[0].Rows[0]["publish_month"].ToString());
         issue.publishYear = ParseHelper.ParseInt(ds.Tables[0].Rows[0]["publish_year"].ToString());
         issue.collected = ParseHelper.ParseBool(ds.Tables[0].Rows[0]["collected"].ToString());
         issue.enabled = ParseHelper.ParseBool(ds.Tables[0].Rows[0]["enabled"].ToString());
     }
     return issue;
 }
Пример #7
0
 private List<Issue> FillIssues(DataSet ds)
 {
     List<Issue> issues = new List<Issue>();
     foreach (DataRow row in ds.Tables[0].Rows)
     {
         Issue issue = new Issue();
         issue.id = ParseHelper.ParseInt(row["id"].ToString());
         issue.volumeId = ParseHelper.ParseInt(row["volume_id"].ToString());
         issue.name = row["name"].ToString();
         issue.issueNumber = ParseHelper.ParseFloat(row["issue_number"].ToString());
         issue.publishMonth = ParseHelper.ParseInt(row["publish_month"].ToString());
         issue.publishYear = ParseHelper.ParseInt(row["publish_year"].ToString());
         issue.collected = ParseHelper.ParseBool(row["collected"].ToString());
         issue.enabled = ParseHelper.ParseBool(row["enabled"].ToString());
         issues.Add(issue);
     }
     return issues;
 }
Пример #8
0
 public bool Update(Issue issue)
 {
     using (SqlConnection con = new SqlConnection(constring))
     {
         con.Open();
         string sql = "update issue set volume_id = @volume_id, name = @name, issue_number = @issue_number, issue_number_suffix = @issue_number_suffix, publish_month = @publish_month, publish_year = @publish_year, enabled = @enabled where id = @id";
         SqlCommand command = new SqlCommand(sql, con);
         command.Parameters.AddWithValue("@id", issue.id);
         command.Parameters.AddWithValue("@volume_id", issue.volumeId);
         command.Parameters.AddWithValue("@name", TruncateString(issue.name, 100));
         command.Parameters.AddWithValue("@issue_number", issue.issueNumber);
         command.Parameters.AddWithValue("@issue_number_suffix", issue.issueNumberSuffix);
         command.Parameters.AddWithValue("@publish_month", issue.publishMonth);
         command.Parameters.AddWithValue("@publish_year", issue.publishYear);
         //command.Parameters.AddWithValue("@collected", issue.collected); Don't want to update collected values
         command.Parameters.AddWithValue("@enabled", issue.enabled);
         int result = command.ExecuteNonQuery();
         if (result == 1)
         {
             return true;
         }
         else
         {
             return false;
         }
     }
 }
Пример #9
0
 public bool Insert(Issue issue)
 {
     using (SqlConnection con = new SqlConnection(constring))
     {
         con.Open();
         string sql = "insert into issue "
                 + "(id, volume_id, name, issue_number, issue_number_suffix, publish_month, publish_year, collected, enabled) "
                 + "values (@id, @volume_id, @name, @issue_number, @issue_number_suffix, @publish_month, @publish_year, @collected, @enabled)";
         SqlCommand command = new SqlCommand(sql, con);
         command.Parameters.AddWithValue("@id", issue.id);
         command.Parameters.AddWithValue("@volume_id", issue.volumeId);
         command.Parameters.AddWithValue("@name", TruncateString(issue.name, 100));
         command.Parameters.AddWithValue("@issue_number", issue.issueNumber);
         command.Parameters.AddWithValue("@issue_number_suffix", issue.issueNumberSuffix);
         command.Parameters.AddWithValue("@publish_month", issue.publishMonth);
         command.Parameters.AddWithValue("@publish_year", issue.publishYear);
         command.Parameters.AddWithValue("@collected", issue.collected);
         command.Parameters.AddWithValue("@enabled", issue.enabled);
         int result = command.ExecuteNonQuery();
         if (result == 1)
         {
             return true;
         }
         else
         {
             return false;
         }
     }
 }
Пример #10
0
        public bool Save(Issue issue)
        {
            if (IssueExists(issue.id))
            {
                return Update(issue);
            }

            return Insert(issue);
        }