private static bool AddTerritoryCard(ref TerritoryCardData card)
 {
     try {
         using (var db = new TerritoryCardsDataContext()) {
             var newCard = TerritoryCardData.Copy(card);
             db.TerritoryCardItems.InsertOnSubmit(newCard);
             db.SubmitChanges();
             card.ItemId = newCard.ItemId;
             return(card.ItemId > 0);
         }
     }
     catch {
         return(false);
     }
 }
        public static TerritoryCardData GetTerritoryCard(int itemId)
        {
            try {
                using (var db = new TerritoryCardsDataContext()) {
                    var c = db.TerritoryCardItems.Single(x => x.ItemId == itemId);
                    if (c == null)
                    {
                        return(null);
                    }

                    return(TerritoryCardData.Copy(c));
                }
            }
            catch (InvalidOperationException e) {
                return(null);
            }
        }
        public static TerritoryCardData[] GetTerritoryCards(SortOrder so)
        {
            try {
                using (var db = new TerritoryCardsDataContext()) {
                    var qry = from x in db.TerritoryCardItems
                              orderby x.DateCreated
                              select x;

                    if (!qry.Any())
                    {
                        return(null);
                    }
                    return(qry.Select(c => TerritoryCardData.Copy(c)).ToArray());
                }
            }
            catch {
                return(null);
            }
        }