public static void Update(AuthorViewModel target) { AuthorDao dao = new AuthorDao(); dao.Update(target.ToEntity()); s_logger.Debug($"UPDATE Author:{target}"); }
public static void Create(AuthorViewModel target) { AuthorDao dao = new AuthorDao(); dao.Insert(target.ToEntity()); s_logger.Debug($"INSERT Author:{target}"); }
public IAuthorDao Create(string authorName) { var dao = new AuthorDao { Name = authorName }; Context.Authors.Add(dao); Context.SaveChanges(); return dao; }
public JsonResult Edit(Author author) { // result return true if update successfully, else return false var result = AuthorDao.CreateOrEdit(author) > 0; return(Json(result)); }
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 JsonResult Delete(int id) { // result return true if delete successfully, else return false var result = AuthorDao.Delete(id) > 0; return(Json(result)); }
public JsonResult Create(Author author) { author.IsActive = true; var result = AuthorDao.CreateOrEdit(author) > 0; return(Json(result)); }
public static void Delete(Guid id) { AuthorDao dao = new AuthorDao(); dao.DeleteWhereIDIs(id); s_logger.Debug($"DELETE Author:{id}"); }
public void Create() { ResetDatabase(); AuthorDao authorDao = (AuthorDao)Container[typeof(AuthorDao)]; BlogDao blogDao = (BlogDao)Container[typeof(BlogDao)]; PostDao postDao = (PostDao)Container[typeof(PostDao)]; Author author = new Author("hamilton verissimo", "hammett", "mypass"); Blog blog = new Blog("hammett's blog", "my thoughts.. ugh!", "default", author); Post post = new Post("My first entry", "This is my first entry", DateTime.Now); post.Blog = blog; authorDao.Create(author); blogDao.Create(blog); postDao.Create(post); IList posts = postDao.Find(); Assert.AreEqual(1, posts.Count); Post comparisson = (Post)posts[0]; Assert.AreEqual(post.Title, comparisson.Title); Assert.AreEqual(post.Contents, comparisson.Contents); }
public ActionResult Author(string id) { var TacGia = new AuthorDao().GetTacgiaByTenTacGia(id); var listAuthor = new ProductDao().GetLoaiSachByIDTacGia(TacGia.MaTacGia); return(View(listAuthor)); }
public ActionResult ListAllProductByAuthor(long id, int page = 1, int pageSize = 6) { Session[Constants.CURRENT_URL] = HttpContext.Request.RawUrl; Session[Constants.CATEGORY_ACTIVE] = null; Session[Constants.CATE_ID] = Convert.ToInt64(0); Session[Constants.AUTHOR_ID] = id; var product = new ProductDao().ListProductbyAuthor(id); var author = new AuthorDao().GetDetail(id); Session[Constants.LISTPRODUCT] = product; Session[Constants.LISTPRODUCT_VIEWNAME] = "Index"; Session[Constants.LISTPRODUCT_ACTIONNAME] = "ListAllProductByAuthor"; Session[Constants.MINPRICE] = Convert.ToDecimal(0); Session[Constants.MAXPRICE] = decimal.MaxValue; Session[Constants.SORT_ACTIVE] = 1; Session[Constants.SORTSTATUS_ACTIVE] = 1; Session[Constants.STATUSNAME_PRODUCT] = "Tìm theo tác giả : " + author.Name; int totalRecord = product.Count(); string link = "/san-pham-theo-tac-gia-" + id + "?"; var listproduct = product.Skip((page - 1) * pageSize).Take(pageSize).ToList(); SetPagination(totalRecord, pageSize, page, link); if (Session[Constants.USER_INFO] != null) { new LogDao().SetLog("ListAllProductByAuthor", "Tác giả : " + author.Name.ToString() + ", Trang : " + page.ToString(), ((User)Session[Constants.USER_INFO]).ID); } return(View((string)Session[Constants.LISTPRODUCT_VIEWNAME], listproduct)); }
private void ImportAuthor(ILibrary libManager, AuthorViewModel add) { AuthorDao authorDao = new AuthorDao(); authorDao.Insert(add.ToEntity(), _dataOpUnit.CurrentConnection); libManager.AuthorManager.Authors.Add(add); }
public ActionResult Delete(Author author) { if (((User)Session[Constants.USER_INFO]).GroupID == Constants.GROUP_ADMIM) { var setnull = new ProductDao().SetNullAuthor(author.ID); if (setnull) { var result = new AuthorDao().Remove(author); if (result) { SetAlert("Xoá Author thành công", Constants.ALERTTYPE_SUCCESS); new LogDao().SetLog("Admin_Author_Delete", "Xoá Author thành công", ((User)Session[Constants.USER_INFO]).ID); return(RedirectToAction("Index", "Author")); } else { SetAlert("Xoá Author không thành công", Constants.ALERTTYPE_ERROR); new LogDao().SetLog("Admin_Author_Delete", "Xoá Author không thành công", ((User)Session[Constants.USER_INFO]).ID); return(RedirectToAction("Index", "Author")); } } } SetAlert("Tài khoản của bạn không có quyền", Constants.ALERTTYPE_ERROR); new LogDao().SetLog("Admin_Author_Delete", "Tài khoản của bạn không có quyền", ((User)Session[Constants.USER_INFO]).ID); return(RedirectToAction("Index", "Author")); }
public void FindBlogPosts() { ResetDatabase(); AuthorDao authorDao = (AuthorDao)Container[typeof(AuthorDao)]; BlogDao blogDao = (BlogDao)Container[typeof(BlogDao)]; Author author = new Author("hamilton verissimo", "hammett", "mypass"); Blog blog = new Blog("hammett's blog", "my thoughts.. ugh!", "default", author); authorDao.Create(author); blogDao.Create(blog); Post post1 = new Post("My first entry", "This is my first entry", DateTime.Now); post1.Blog = blog; Post post2 = new Post("My second entry", "This is my second entry", DateTime.Now); post2.Blog = blog; PostDao postDao = (PostDao)Container[typeof(PostDao)]; postDao.Create(post1); postDao.Create(post2); IList posts = postDao.Find(blog); Assert.AreEqual(2, posts.Count); }
private void SetAuthorTo(IAuthorManager authorManager, BookViewModel add) { IDConversionDao idcDao = new IDConversionDao(); AuthorDao authorDao = new AuthorDao(); var idc = idcDao.FindBy(new Dictionary <string, object>() { { "TableName", "Author" }, { "ForeignID", add.AuthorID } }, _dataOpUnit.CurrentConnection); if (idc.Count() == 1) { add.Author = authorDao.FindBy(new Dictionary <string, object>() { { "ID", idc.Single().DomesticID } }, _dataOpUnit.CurrentConnection).SingleOrDefault().ToViewModel(); } else { add.Author = authorDao.FindBy(new Dictionary <string, object>() { { "ID", add.AuthorID } }, _dataOpUnit.CurrentConnection).SingleOrDefault().ToViewModel(); } authorManager.ObserveAuthorCount(); }
public ActionResult Index(int page = 1, int pageSize = 5) { var dao = new AuthorDao(); var model = dao.ListAllPaging(page, pageSize); return(View(model)); }
public static List <AuthorDto> GetAllNotDeletedAuthors() { if (allNotDeletedAuthors == null || allNotDeletedAuthors.Count == 0) { allNotDeletedAuthors = AuthorDao.Where(n => n.IsDeleted == false).ToList(); } return(allNotDeletedAuthors); }
public override void DropTable(IConnection connection) { AuthorDao dao = new AuthorDao(typeof(VersionOrigin)); dao.CurrentConnection = connection; dao.DropTable(); ++ModifiedCount; }
public ActionResult Detail(long id) { SetActiveSlideBar(Constants.SLIDEBAR_AD_AUTHOR); var AuthorModel = new AuthorDao().GetDetail(id); new LogDao().SetLog("Admin_Author_Detail", null, ((User)Session[Constants.USER_INFO]).ID); return(View(AuthorModel)); }
// GET: Admin/Author public ActionResult Index() { SetActiveSlideBar(Constants.SLIDEBAR_AD_AUTHOR); var AuthorModel = new AuthorDao().ListAllAuthor(); new LogDao().SetLog("Admin_Author_Index", null, ((User)Session[Constants.USER_INFO]).ID); return(View(AuthorModel)); }
public static List <string> GetAuthorNameList() { if (authorList == null || authorList.Count == 0) { authorList = AuthorDao.Where(n => n.IsDeleted == false).ToList(); } return(authorList.Select(n => n.Name).ToList()); }
public static List <AuthorDto> GetAllAuthors() { if (authorList == null || authorList.Count == 0) { authorList = AuthorDao.GetAll(); } return(authorList); }
// // GET: /Admin/Author/ public ActionResult Index(string searchString, int page = 1, int pageSize = 10) { var dao = new AuthorDao(); var model = dao.ListAllpaging(searchString, page, pageSize); ViewBag.searchString = searchString; return(View(model)); }
public ActionResult Create(Author author, HttpPostedFileBase postedFile) { if (((User)Session[Constants.USER_INFO]).GroupID == Constants.GROUP_ADMIM) { if (ModelState.IsValid) { var userinfo = (User)Session[Constants.USER_INFO]; string path; string filename = ""; string fullfilename = ""; if (postedFile == null) { fullfilename = "computer-icons-user-profile-login-my-account-icon-png-clip-art.png"; path = Path.Combine(Server.MapPath("~/Data/ImgAuthor"), fullfilename); //postedFile.SaveAs(path); } else { //Luu ten fie, luu y bo sung thu vien using System.IO; filename = Path.GetFileName(postedFile.FileName); fullfilename = filename.Split('.')[0] + "(" + DateTime.Now.Year.ToString() + DateTime.Now.Month.ToString() + DateTime.Now.Day.ToString() + DateTime.Now.Hour.ToString() + DateTime.Now.Minute.ToString() + DateTime.Now.Second.ToString() + DateTime.Now.Millisecond.ToString() + ")." + filename.Split('.')[1]; //Luu duong dan cua file path = Path.Combine(Server.MapPath("~/Data/ImgAuthor"), fullfilename); postedFile.SaveAs(path); } author.Image = fullfilename; author.Status = true; author.CreatedBy = userinfo.UserName; author.MetaTitle = Unicode.RemoveUnicode(author.Name).Replace(" ", "-").ToLower().ToString(); author.Tag = Unicode.RemoveUnicode(author.Name).ToLower().ToString(); //author.CreatedBy = Session[Constants.USER_USERNAME].ToString(); long id = new AuthorDao().Insert(author); if (id > 0) { SetAlert("Tạo Author thành công", Constants.ALERTTYPE_SUCCESS); new LogDao().SetLog("Admin_Author_Create", "Tạo Author thành công", ((User)Session[Constants.USER_INFO]).ID); return(RedirectToAction("Index", "Author")); } else { SetAlert("Tạo Author không thành công", Constants.ALERTTYPE_ERROR); new LogDao().SetLog("Admin_Author_Create", "Tạo Author không thành công", ((User)Session[Constants.USER_INFO]).ID); return(RedirectToAction("Index", "Author")); } } else { ModelState.AddModelError("", "Dữ liệu không lệ"); new LogDao().SetLog("Admin_Author_Create", "Dữ liệu không hợp lệ", ((User)Session[Constants.USER_INFO]).ID); return(View("Create", author)); } } SetAlert("Tài khoản của bạn không có quyền", Constants.ALERTTYPE_ERROR); new LogDao().SetLog("Admin_Author_Create", "Tài khoản của bạn không có quyền", ((User)Session[Constants.USER_INFO]).ID); return(RedirectToAction("Index", "Author")); }
public ActionResult Author(long Au_id) { var author = new AuthorDao().ViewDetail(Au_id); ViewBag.Author = author; var model = new BookDao().ListByAuthor(Au_id); return(View(model)); }
public static bool Exists(Guid authorID, DataOperationUnit dataOpUnit = null) { AuthorDao dao = new AuthorDao(); return(dao.CountBy(new Dictionary <string, object>() { { "ID", authorID } }, dataOpUnit?.CurrentConnection) > 0); }
public static bool Exists(string name, DataOperationUnit dataOpUnit = null) { AuthorDao dao = new AuthorDao(); return(dao.CountBy(new Dictionary <string, object>() { { "Name", name } }, dataOpUnit?.CurrentConnection) > 0); }
public static AuthorViewModel FindBy(Guid id, DataOperationUnit dataOpUnit = null) { AuthorDao dao = new AuthorDao(); return(dao.FindBy(new Dictionary <string, object>() { { "ID", id } }, dataOpUnit?.CurrentConnection).SingleOrDefault().ToViewModel()); }
public static IEnumerable <Author> FindBy(string name, DataOperationUnit dataOpUnit = null) { AuthorDao dao = new AuthorDao(); return(dao.FindBy(new Dictionary <string, object>() { { "Name", name } }, dataOpUnit?.CurrentConnection)); }
public ActionResult Partial_Menu() { var cate = new ProductCategoryDao().ListAllProductCategoryActive().OrderBy(x => x.Name).ToList(); var aut = new AuthorDao().ListAllAuthorActive().OrderBy(x => x.Name).ToList(); ViewBag.Category = cate; ViewBag.Author = aut; return(PartialView()); }
public JsonResult ChangeStatus(long id) { var result = new AuthorDao().ChangeStatus(id); return(Json(new { status = result })); }
//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 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 static void WriteAllAuthor(int begin) { for (int i = begin; i <= 978; i++) { Author a = GetAuthor(i); int result = 0; using (AuthorDao dao = new AuthorDao()) result = dao.add(a); if (result < 0) throw new ApplicationException("插入错误"); } Console.WriteLine("数据下载完毕"); }
public ActionResult Import() { object results = "Pouet"; ElementDao dao = new ElementDao(cvDb); AuthorDao authDao = new AuthorDao(cvDb); List<Author> authors = authDao.GetAuthors(); List<Element> newWsElementsId = dao.GetAllElements(true).ToList(); // Appel à l'ancien WS OldWSRetriever retriever = new OldWSRetriever(); bool mergeComplete = false; int page = 1; int count = 0; while (mergeComplete == false) { List<Element> elements = retriever.GetElements(page); if (elements == null || elements.Count == 0) { mergeComplete = true; } else { foreach (Element oldE in elements) { if (newWsElementsId.Where(newE => newE.Title.ToLowerInvariant() == oldE.Title.ToLowerInvariant()).Count() == 0) { // Auteur Author aut = authors.Where(a => a.Name.ToLower() == oldE.Author.Name.ToLowerInvariant()).FirstOrDefault(); if (aut != null) { oldE.Author = aut; count++; // Ajout if (dao.Create(oldE) == false) { throw dao.LastException; } } } else { mergeComplete = true; break; } } if (mergeComplete == false) { page++; } } } results = count + " élements ajoutés sur " + page + " pages."; return View(results); }
public Element ToElement() { AuthorDao autdao = new AuthorDao(cvDb); var authors = autdao.GetAuthors(); Element e = null; if (Type == "word") { Word w = new Word(); if (string.IsNullOrEmpty(Details1) == false && string.IsNullOrEmpty(Content1) == false) { w.Definitions.Add(new Definition() { Id = IdDef1, Content = Content1, Details = Details1, WordId = w.Id }); } if (string.IsNullOrEmpty(Details2) == false && string.IsNullOrEmpty(Content2) == false) { w.Definitions.Add(new Definition() { Id = IdDef2, Content = Content2, Details = Details2, WordId = w.Id }); } if (string.IsNullOrEmpty(Details3) == false && string.IsNullOrEmpty(Content3) == false) { w.Definitions.Add(new Definition() { Id = IdDef3, Content = Content3, Details = Details3, WordId = w.Id }); } e = w; } else { Contrepeterie ctp = new Contrepeterie(); ctp.Content = Content; ctp.Solution = Solution; e = ctp; } e.Author = authors.Where(a => a.Id == AuthorId).FirstOrDefault(); e.Id = ElementId; e.Title = Title; e.Date = Date; e.FavoriteCount = VoteCount; return e; }
public ElementViewModel() { AuthorDao autdao = new AuthorDao(cvDb); Authors = autdao.GetAuthors(); }
//向数据库写一个作者 public static void WriteAuthor(int id) { Author a = GetAuthor(id); int result = 0; using (AuthorDao dao = new AuthorDao()) result = dao.add(a); Console.WriteLine("已经写入" + result + "个作者"); }