public ActionResult Delete(Publisher publisher)
 {
     if (((User)Session[Constants.USER_INFO]).GroupID == Constants.GROUP_ADMIM)
     {
         var setnull = new ProductDao().SetNullPublisher(publisher.ID);
         if (setnull)
         {
             var result = new PublisherDao().Remove(publisher);
             if (result)
             {
                 SetAlert("Xoá Publisher thành công", Constants.ALERTTYPE_SUCCESS);
                 new LogDao().SetLog("Admin_Publisher_Delete", "Xoá Publisher thành công", ((User)Session[Constants.USER_INFO]).ID);
                 return(RedirectToAction("Index", "Publisher"));
             }
             else
             {
                 SetAlert("Xoá Publisher không thành công", Constants.ALERTTYPE_ERROR);
                 new LogDao().SetLog("Admin_Publisher_Delete", "Xoá Publisher không thành công", ((User)Session[Constants.USER_INFO]).ID);
                 return(RedirectToAction("Index", "Publisher"));
             }
         }
     }
     SetAlert("Tài khoản của bạn không có quyền", Constants.ALERTTYPE_ERROR);
     new LogDao().SetLog("Admin_Publisher_Delete", "Tài khoản của bạn không có quyền", ((User)Session[Constants.USER_INFO]).ID);
     return(RedirectToAction("Index", "Publisher"));
 }
        public ActionResult Index(int page = 1, int pageSize = 5)
        {
            var dao   = new PublisherDao();
            var model = dao.ListAllPaging(page, pageSize);

            return(View(model));
        }
        public ActionResult Detail(long id)
        {
            SetActiveSlideBar(Constants.SLIDEBAR_AD_PUBLISHER);
            var PublisherModel = new PublisherDao().GetDetail(id);

            new LogDao().SetLog("Admin_Publisher_Detail", null, ((User)Session[Constants.USER_INFO]).ID);
            return(View(PublisherModel));
        }
        // GET: Admin/Publisher
        public ActionResult Index()
        {
            SetActiveSlideBar(Constants.SLIDEBAR_AD_PUBLISHER);
            var PublisherModel = new PublisherDao().ListAllPublisher();

            new LogDao().SetLog("Admin_Publisher_Index", null, ((User)Session[Constants.USER_INFO]).ID);
            return(View(PublisherModel));
        }
Beispiel #5
0
 public static List <PublisherDto> GetAllNotDeletedPublishers()
 {
     if (allNotDeletedPublishers == null || allNotDeletedPublishers.Count == 0)
     {
         allNotDeletedPublishers = PublisherDao.Where(n => n.IsDeleted == false).ToList();
     }
     return(allNotDeletedPublishers);
 }
Beispiel #6
0
 public static List <string> GetPublisherNameList()
 {
     if (publisherList == null || publisherList.Count == 0)
     {
         publisherList = PublisherDao.Where(n => n.IsDeleted == false).ToList();
     }
     return(publisherList.Select(n => n.Name).ToList());
 }
Beispiel #7
0
        public static int Insert(PublisherDto dto)
        {
            int id = PublisherDao.Insert(dto);

            dto.PublisherId = id;
            allNotDeletedPublishers.Add(dto);
            allNotDeletedPublishers = allNotDeletedPublishers.OrderByDescending(n => n.PublisherId).ToList();
            return(id);
        }
        public JsonResult ChangeStatus(long id)
        {
            var result = new PublisherDao().ChangeStatus(id);

            return(Json(new
            {
                status = result
            }));
        }
 public ActionResult Edit(long id)
 {
     if (((User)Session[Constants.USER_INFO]).GroupID == Constants.GROUP_ADMIM)
     {
         SetActiveSlideBar(Constants.SLIDEBAR_AD_PUBLISHER);
         var PublisherModel = new PublisherDao().GetDetail(id);
         new LogDao().SetLog("Admin_Publisher_Edit", null, ((User)Session[Constants.USER_INFO]).ID);
         return(View(PublisherModel));
     }
     SetAlert("Tài khoản của bạn không có quyền", Constants.ALERTTYPE_ERROR);
     new LogDao().SetLog("Admin_Publisher_Edit", "Tài khoản của bạn không có quyền", ((User)Session[Constants.USER_INFO]).ID);
     return(RedirectToAction("Index", "Publisher"));
 }
Beispiel #10
0
        public void SetViewBag(long?selectedId = null)
        {
            var dao1 = new AuthorDao();

            ViewBag.MaTG = new SelectList(dao1.ListAll(), "MaTG", "TenTG", selectedId);
            var dao2 = new CategoryDao();

            ViewBag.MaDM = new SelectList(dao2.ListAll(), "MaDM", "TenDM", selectedId);
            var dao3 = new PublisherDao();

            ViewBag.MaNXB = new SelectList(dao3.ListAll(), "MaNXB", "TenNXB", selectedId);
            var dao4 = new PromotionDao();

            ViewBag.MaKM = new SelectList(dao4.ListAl(), "MaKM", "MaKM", selectedId);
        }
Beispiel #11
0
        public static bool Update(PublisherDto dto)
        {
            PublisherDto oldDto = allNotDeletedPublishers.FirstOrDefault(n => n.PublisherId == dto.PublisherId);
            bool         result = PublisherDao.Update(dto);

            if (result)
            {
                if (oldDto != null)
                {
                    allNotDeletedPublishers.Remove(oldDto);
                }
                allNotDeletedPublishers.Add(dto);
                allNotDeletedPublishers = allNotDeletedPublishers.OrderBy(n => n.PublisherId).ToList();
            }
            return(result);
        }
        //Render page Create new book
        public ActionResult Create()
        {
            //get list categories existing and assign for viewbag
            SelectList categories = new SelectList(CategoryDao.GetAllCategory(), "categoryID", "categoryName");

            ViewBag.Categories = categories;
            //get list authors existing and assign for viewbag
            SelectList authors = new SelectList(AuthorDao.GetListAuthors(), "authorID", "authorName");

            ViewBag.Authors = authors;
            //get list publishers existing and assign for viewbag
            SelectList publishers = new SelectList(PublisherDao.GetListPublisher(), "publisherID", "publisherName");

            ViewBag.Publishers = publishers;

            return(PartialView("_CreateBook", new Book()));
        }
Beispiel #13
0
        public ActionResult Searching(string searchkey, int page = 1, int pageSize = 6)
        {
            if (searchkey == null)
            {
                searchkey = (string)Session[Constants.LISTPRODUCT_SEARCHKEY];
            }
            Session[Constants.LISTPRODUCT_SEARCHKEY] = searchkey;
            Session[Constants.CURRENT_URL]           = HttpContext.Request.RawUrl;

            var             author             = new AuthorDao().ListAuthorBySearchKey(searchkey);
            var             publisher          = new PublisherDao().ListPublisherBySearchKey(searchkey);
            var             productsearch      = new ProductDao().ListProductBySearching(searchkey);
            var             productbyauthor    = new ProductDao().ListProductByListAuthor(author);
            var             productbypublisher = new ProductDao().ListProductByListPublisher(publisher);
            var             listsearch         = productsearch.Concat(productbyauthor).Concat(productbypublisher).ToList();
            ProductComparer productComparer    = new ProductComparer();

            listsearch = listsearch.Distinct(productComparer).OrderByDescending(x => x.Name).ToList();

            Session[Constants.CATEGORY_ACTIVE]        = null;
            Session[Constants.CATE_ID]                = Convert.ToInt64(0);
            Session[Constants.LISTPRODUCT]            = listsearch;
            Session[Constants.LISTPRODUCT_VIEWNAME]   = "Index";
            Session[Constants.LISTPRODUCT_ACTIONNAME] = "Searching";

            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 kiếm : " + searchkey;

            int    totalRecord = listsearch.Count();
            string link        = "/ProductClient/Searching?searchkey=" + searchkey + "&";
            var    listfinal   = listsearch.Skip((page - 1) * pageSize).Take(pageSize).ToList();

            SetPagination(totalRecord, pageSize, page, link);

            if (Session[Constants.USER_INFO] != null)
            {
                new LogDao().SetLog("Searching", "Tìm kiếm : " + searchkey.ToString() + ", Trang : " + page.ToString(), ((User)Session[Constants.USER_INFO]).ID);
            }

            return(View((string)Session[Constants.LISTPRODUCT_VIEWNAME], listfinal));
        }
 public ActionResult Edit(NhaXB xb)
 {
     if (ModelState.IsValid)
     {
         var dao    = new PublisherDao();
         var result = dao.Update(xb);
         if (result)
         {
             SetAlert("Sửa thông tin nhà xuất bản thành công", "success");
             return(RedirectToAction("Index", "Publisher"));
         }
         else
         {
             ModelState.AddModelError("", "Cập nhật thông tin nhà xuất bản không thành công");
         }
     }
     return(View("Index"));
 }
 public ActionResult Create(NhaXB tt)
 {
     if (ModelState.IsValid)
     {
         var  dao = new PublisherDao();
         long id  = dao.Insert(tt);
         if (id > 0)
         {
             SetAlert("Thêm nhà xuất bản thành công", "success");
             return(RedirectToAction("Index", "Publisher"));
         }
         else
         {
             ModelState.AddModelError("", "Thêm nhà xuất bản không thành công");
         }
     }
     return(View("Index"));
 }
        //Render page edit book by book id
        public ActionResult Edit(int id)
        {
            //get book need to edit
            var book = BookDao.GetBook(id);

            //store older picture if user don't choose new picture
            oldPicture = book.Picture;
            //get list categories existing and assign for viewbag
            SelectList categories = new SelectList(CategoryDao.GetAllCategory(), "categoryID", "categoryName", book.Category.CategoryName);

            ViewBag.Categories = categories;
            //get list authors existing and assign for viewbag
            SelectList authors = new SelectList(AuthorDao.GetListAuthors(), "authorID", "authorName", book.Author.AuthorName);

            ViewBag.Authors = authors;
            //get list publishers existing and assign for viewbag
            SelectList publishers = new SelectList(PublisherDao.GetListPublisher(), "publisherID", "publisherName", book.Publisher.PublisherName);

            ViewBag.Publishers = publishers;
            return(View("_EditBook", book));
        }
Beispiel #17
0
        public static int GetPublisherId(string name)
        {
            if (publisherList == null || publisherList.Count == 0)
            {
                publisherList = PublisherDao.Where(n => n.IsDeleted == false).ToList();
            }
            PublisherDto dto = publisherList.FirstOrDefault(n => n.Name.Equals(name));

            if (dto == null)
            {
                dto = PublisherDao.Where(n => n.Name.Equals(name)).ToList().FirstOrDefault();
            }
            if (dto == null)
            {
                return(0);
            }
            else
            {
                return(dto.PublisherId);
            }
        }
        public ActionResult Edit(Publisher publisher)
        {
            if (((User)Session[Constants.USER_INFO]).GroupID == Constants.GROUP_ADMIM)
            {
                if (ModelState.IsValid)
                {
                    var userinfo = (User)Session[Constants.USER_INFO];
                    publisher.ModifiedBy = userinfo.UserName;
                    publisher.MetaTitle  = Unicode.RemoveUnicode(publisher.Name).Replace(" ", "-").ToLower().ToString();
                    publisher.Tag        = Unicode.RemoveUnicode(publisher.Name).ToLower().ToString();
                    //publisher.ModifiedBy = Session[Constants.USER_USERNAME].ToString();

                    var result = new PublisherDao().Update(publisher);

                    if (result)
                    {
                        //Cập nhật lại hình sau khi update
                        SetAlert("Thay đổi thông tin Publisher thành công", Constants.ALERTTYPE_SUCCESS);
                        new LogDao().SetLog("Admin_Publisher_Edit", "Thay đổi thông tin Publisher thành công", ((User)Session[Constants.USER_INFO]).ID);
                        return(RedirectToAction("Index", "Publisher"));
                    }
                    else
                    {
                        SetAlert("Thay đổi thông tin Publisher không thành công", Constants.ALERTTYPE_ERROR);
                        new LogDao().SetLog("Admin_Publisher_Edit", "Thay đổi thông tin Publisher không thành công", ((User)Session[Constants.USER_INFO]).ID);
                        return(RedirectToAction("Index", "Publisher"));
                    }
                }
                else
                {
                    ModelState.AddModelError("", "Dữ liệu không lệ");
                    new LogDao().SetLog("Admin_Publisher_Edit", "Dữ liệu không hợp lệ", ((User)Session[Constants.USER_INFO]).ID);
                    return(View("Edit", publisher));
                }
            }
            SetAlert("Tài khoản của bạn không có quyền", Constants.ALERTTYPE_ERROR);
            new LogDao().SetLog("Admin_Publisher_Edit", "Tài khoản của bạn không có quyền", ((User)Session[Constants.USER_INFO]).ID);
            return(RedirectToAction("Index", "Publisher"));
        }
        public ActionResult Create(Publisher publisher)
        {
            if (((User)Session[Constants.USER_INFO]).GroupID == Constants.GROUP_ADMIM)
            {
                if (ModelState.IsValid)
                {
                    var userinfo = (User)Session[Constants.USER_INFO];
                    publisher.Status    = true;
                    publisher.CreatedBy = userinfo.UserName;
                    publisher.MetaTitle = Unicode.RemoveUnicode(publisher.Name).Replace(" ", "-").ToLower().ToString();
                    publisher.Tag       = Unicode.RemoveUnicode(publisher.Name).ToLower().ToString();
                    //publisher.CreatedBy = Session[Constants.USER_USERNAME].ToString();

                    long id = new PublisherDao().Insert(publisher);
                    if (id > 0)
                    {
                        SetAlert("Tạo Publisher thành công", Constants.ALERTTYPE_SUCCESS);
                        new LogDao().SetLog("Admin_Publisher_Create", "Tạo Publisher thành công", ((User)Session[Constants.USER_INFO]).ID);
                        return(RedirectToAction("Index", "Publisher"));
                    }
                    else
                    {
                        SetAlert("Tạo Publisher không thành công", Constants.ALERTTYPE_ERROR);
                        new LogDao().SetLog("Admin_Publisher_Create", "Tạo Publisher không thành công", ((User)Session[Constants.USER_INFO]).ID);
                        return(RedirectToAction("Index", "Publisher"));
                    }
                }
                else
                {
                    ModelState.AddModelError("", "Dữ liệu không lệ");
                    new LogDao().SetLog("Admin_Publisher_Create", "Dữ liệu không hợp lệ", ((User)Session[Constants.USER_INFO]).ID);
                    return(View("Create", publisher));
                }
            }
            SetAlert("Tài khoản của bạn không có quyền", Constants.ALERTTYPE_ERROR);
            new LogDao().SetLog("Admin_Publisher_Create", "Tài khoản của bạn không có quyền", ((User)Session[Constants.USER_INFO]).ID);
            return(RedirectToAction("Index", "Publisher"));
        }
Beispiel #20
0
 public static bool Delete(PublisherDto dto)
 {
     allNotDeletedPublishers.Remove(dto);
     return(PublisherDao.Delete(dto.PublisherId));
 }
        public ActionResult Edit(int id)
        {
            var xb = new PublisherDao().ViewDetail(id);

            return(View(xb));
        }