Created
December 9, 2009 20:53
-
-
Save benmills/252803 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Data; | |
using System.Configuration; | |
using System.Collections.Generic; | |
using System.Linq; | |
using System.Web; | |
using System.Web.Security; | |
using System.Web.UI; | |
using System.Web.UI.HtmlControls; | |
using System.Web.UI.WebControls; | |
using System.Web.UI.WebControls.WebParts; | |
using System.Xml.Linq; | |
using threeListData; | |
namespace ThreeList { | |
public class ThreeListDal { | |
public threeListDbDataContext db; | |
public ThreeListDal() { | |
db = new threeListDbDataContext(); | |
} | |
// Read | |
public List<City> get_cities() { | |
List<city> db_cities = db.cities.ToList(); | |
List<City> cities = new List<City>(); | |
foreach (city i in db_cities) { | |
cities.Add(new City(i.id, i.name)); | |
} | |
return cities; | |
} | |
public List<Category> get_categories() { | |
List<category> db_categories = db.categories.ToList(); | |
List<Category> categories = new List<Category>(); | |
foreach (category i in db_categories) { | |
categories.Add(new Category(i.id, i.name)); | |
} | |
return categories; | |
} | |
public post get_post(int id) { | |
return db.posts.First(c => c.id == id); | |
} | |
//public List<Post> get_posts_by_city(int city_id) { | |
//} | |
//public List<Post> get_posts_by_category(int category_id) { | |
//} | |
// Update | |
public void save_post(post post) { | |
if (post.id == 0) { | |
db.posts.InsertOnSubmit(post); | |
} | |
db.SubmitChanges(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment