public void Find() { ResetDatabase(); AuthorDao dao = (AuthorDao)Container[typeof(AuthorDao)]; Author author1 = new Author("hamilton verissimo", "hammett", "mypass"); Author author2 = new Author("john turturro", "turturro", "mypass"); dao.Create(author1); dao.Create(author2); Author found = dao.Find("hammett"); Assert.IsNotNull(found); Assert.AreEqual(author1.Name, found.Name); Assert.AreEqual(author1.Login, found.Login); Assert.AreEqual(author1.Password, found.Password); found = dao.Find("turturro"); Assert.IsNotNull(found); Assert.AreEqual(author2.Name, found.Name); Assert.AreEqual(author2.Login, found.Login); Assert.AreEqual(author2.Password, found.Password); }
public Blog ObtainBlogByAuthorName(string authorName) { Author author = _authorDao.Find(authorName); if (author == null) { return(null); } return(author.Blogs[0] as Blog); }
public void Create() { ResetDatabase(); AuthorDao dao = (AuthorDao)Container[typeof(AuthorDao)]; Assert.AreEqual(0, dao.Find().Count); Author author = new Author("hamilton verissimo", "hammett", "mypass"); dao.Create(author); IList authors = dao.Find(); Assert.AreEqual(1, authors.Count); Author comparisson = (Author)authors[0]; Assert.AreEqual(author.Name, comparisson.Name); Assert.AreEqual(author.Login, comparisson.Login); Assert.AreEqual(author.Password, comparisson.Password); }
//endregion //region service //todo 暂时只接受分页参数,不接受查询参数 public ActionResult JAuthorList(int draw, int start, int length, AuthorCondnition c) { PagingArgument page = new PagingArgument(); page.start = start; page.size = length; List<Author> data = null; using (AuthorDao dao = new AuthorDao()) data = dao.Find(c, page); DataResponse r = new DataResponse(); r.draw = draw; r.data = data; r.recordsFiltered = page.count; return Json(r, JsonRequestBehavior.AllowGet); }
public void FindAll() { ResetDatabase(); AuthorDao dao = (AuthorDao)Container[typeof(AuthorDao)]; Author author1 = new Author("hamilton verissimo", "hammett", "mypass"); Author author2 = new Author("john turturro", "turturro", "mypass"); dao.Create(author1); dao.Create(author2); IList authors = dao.Find(); Assert.AreEqual(2, authors.Count); }
public void CreateAuthorAndBlog() { ResetDatabase(); AccountService service = (AccountService)Container[typeof(AccountService)]; Author author = new Author("hamilton verissimo", "hammett", "mypass"); Blog blog = new Blog("hammett's blog", "Description", "default", author); service.CreateAccountAndBlog(blog); AuthorDao dao = (AuthorDao)Container[typeof(AuthorDao)]; Assert.AreEqual(1, dao.Find().Count); BlogDao blogdao = (BlogDao)Container[typeof(BlogDao)]; Assert.AreEqual(1, blogdao.Find().Count); }
public virtual bool Authenticate(String login, String password) { if (login == null) { throw new ArgumentNullException("login"); } if (password == null) { throw new ArgumentNullException("password"); } Author author = _authorDao.Find(login); if (author == null || !password.Equals(author.Password)) { return(false); } return(true); }
public static void downloadAllAvatarAvatar() { List<string> temp; PagingArgument page = new PagingArgument(); page.index = 0; page.size = 10; using (AuthorDao dao = new AuthorDao()) { do { temp = dao.Find(null, page).Select(t => t.Image).ToList(); page.index++; foreach (string a in temp) { if (!string.IsNullOrEmpty(a)) downloadAvatar(a, "d:\\avatar"); } } while (temp.Count > 0); } }
public virtual Author ObtainAuthor(String login) { return(_authorDao.Find(login)); }