コード例 #1
0
        private static void editLicense(HomeViewModel vm)
        {
            //SQLServerの接続開始
            DbAccess   dbAccess = new DbAccess();
            SqlCommand cmd      = dbAccess.sqlCon.CreateCommand();

            dbAccess.beginTransaciton();
            try
            {
                HomeDao dao = new HomeDao();
                if (dao.editLicense(vm, cmd, dbAccess) > 0)
                {
                    dbAccess.sqlTran.Commit();
                }
                else
                {
                    dbAccess.sqlTran.Rollback();
                }

                dbAccess.close();
            }
            catch (Exception)
            {
                dbAccess.close();
                throw;
            }
        }
コード例 #2
0
        public object Do_GetHomeShopInfo(BaseApi baseApi)
        {
            HomeShopParam homeShopParam = JsonConvert.DeserializeObject <HomeShopParam>(baseApi.param.ToString());

            if (homeShopParam == null)
            {
                throw new ApiException(CodeMessage.InvalidParam, "InvalidParam");
            }

            HomeDao      homeDao      = new HomeDao();
            HomeShopInfo homeShopInfo = Utils.GetCache <HomeShopInfo>(homeShopParam);

            if (homeShopInfo == null)
            {
                homeShopInfo = homeDao.GetHomeShopInfo(homeShopParam.id);
                if (homeShopInfo == null)
                {
                    throw new ApiException(CodeMessage.InvalidHomePageInfoShop, "InvalidHomePageInfoShop");
                }
                else
                {
                    homeShopInfo.Unique = homeShopParam.GetUnique();
                    Utils.SetCache(homeShopInfo);
                }
            }

            return(homeShopInfo);
        }
コード例 #3
0
 public async Task <IHttpActionResult> RecentLabs()
 {
     return(Json(new
     {
         RecentLabs = await HomeDao.RecentLabs(this)
     }));
 }
コード例 #4
0
        public async Task <ActionResult> Index()
        {
            if (UserId == null)
            {
                return(View());
            }

            return(View(new HomeViewModel
            {
                RecentLabs = await HomeDao.RecentLabs(this)
            }));
        }
コード例 #5
0
        public ActionResult NotificationHome(int page)
        {
            if (Session["LibrarianName"] == null)
            {
                return(RedirectToAction("LibrarianLogin", "Login"));
            }

            var noticeListFromDb = _dbContext.NOTICE_STORE.OrderByDescending(t => t.CreateTime).ToList();
            var noticeList       = new List <Notification>();
            int size             = 10;
            int count            = 0;

            if (TempData.Peek("SearchNoticeList") != null)
            {
                noticeList = (List <Notification>)TempData.Peek("SearchNoticeList");
            }
            else
            {
                foreach (var item in noticeListFromDb)
                {
                    Notification notification = new Notification()
                    {
                        ID          = item.ID,
                        Title       = item.Title,
                        Content     = item.Content,
                        CreateTime  = item.CreateTime.ToString("HH:mm:ss dd/MM/yyyy"),
                        TypeName    = HomeDao.GetTypeNotice(item.TypeID),
                        LibraryName = HomeDao.GetLibraryCode(item.LibID)
                    };

                    noticeList.Add(notification);
                }
            }

            foreach (var item in noticeList)
            {
                count++;
                item.Count = count;
            }

            ViewBag.TypeNoticeList = _dbContext.TYPE_NOTICE.ToList();
            ViewBag.LibraryList    = _dbContext.HOLDING_LIBRARY.Where(t => t.Name != null).ToList();
            ViewBag.FirstIndex     = noticeList.ToPagedList(page, size).FirstItemOnPage;
            ViewBag.LastIndex      = noticeList.ToPagedList(page, size).LastItemOnPage;
            ViewBag.Total          = noticeList.ToPagedList(page, size).TotalItemCount;

            return(View(noticeList.ToPagedList(page, size)));
        }
コード例 #6
0
        // GET: Admin/Home
        public ActionResult Index()
        {
            var daoSoNguoiDUng = new HomeDao().DemSoNguoiDung();

            ViewBag.SoNguoiDung = daoSoNguoiDUng;
            var daoSoDeThi = new HomeDao().DemSoDeThi();

            ViewBag.SoDeThi = daoSoDeThi;
            var daoSoCauHoi = new HomeDao().DemSoCauHoi();

            ViewBag.SoCauHoi = daoSoCauHoi;
            var daoSoTinTuc = new HomeDao().DemSoTinTuc();

            ViewBag.SoTinTuc = daoSoTinTuc;
            return(View());
        }
コード例 #7
0
        private HomeModel getHomeList(int accountId)
        {
            DbAccess   dbAccess = new DbAccess();
            SqlCommand cmd      = dbAccess.sqlCon.CreateCommand();

            try
            {
                HomeDao   dao      = new HomeDao();
                HomeModel homeList = dao.getHomeList(dbAccess, cmd, accountId);

                dbAccess.close();
                return(homeList);
            }
            catch (DbException)
            {
                dbAccess.close();
                throw;
            }
        }
コード例 #8
0
        private List <HomeModel> getHomeList()
        {
            DbAccess   dbAccess = new DbAccess();
            SqlCommand cmd      = dbAccess.sqlCon.CreateCommand();

            try
            {
                HomeDao          dao      = new HomeDao();
                List <HomeModel> homeList = dao.getHomeList(dbAccess, cmd);

                dbAccess.close();
                return(homeList);
            }
            catch (DbException)
            {
                dbAccess.close();
                throw;
            }
        }
コード例 #9
0
        public object Do_GetHomeShopList(BaseApi baseApi)
        {
            HomeDao homeDao = new HomeDao();

            HomeShopList home = Utils.GetCache <HomeShopList>();

            if (home == null)
            {
                home = new HomeShopList();
                home.homeShopList = homeDao.GetHomeShopList();

                if (home.homeShopList == null)
                {
                    throw new ApiException(CodeMessage.InvalidHomePageShop, "InvalidHomePageShop");
                }
                else
                {
                    Utils.SetCache(home);
                }
            }

            return(home);
        }
コード例 #10
0
        public ActionResult CreateNotification(Notice data)
        {
            if (data.TypeID == 0 && data.LibID == 0)
            {
                TempData["ErrorMessage"] = "Vui lòng chọn mục đăng bài và thư viện!";

                return(RedirectToAction("CreateNotification"));
            }

            if (data.TypeID == 0)
            {
                TempData["ErrorMessage"] = "Vui lòng chọn mục đăng bài!";

                return(RedirectToAction("CreateNotification"));
            }

            if (data.LibID == 0)
            {
                TempData["ErrorMessage"] = "Vui lòng chọn thư viện!";

                return(RedirectToAction("CreateNotification"));
            }

            if (string.IsNullOrWhiteSpace(data.Title))
            {
                TempData["ErrorMessage"] = "Vui lòng nhập tiêu đề!";

                return(RedirectToAction("CreateNotification"));
            }

            if (string.IsNullOrWhiteSpace(data.Content))
            {
                TempData["ErrorMessage"] = "Vui lòng thêm nội dung bài viết!";

                return(RedirectToAction("CreateNotification"));
            }

            var isExisted = _dbContext.NOTICE_STORE.ToList().Any(t => t.TypeID == data.TypeID);

            if (isExisted && data.TypeID == 3 || isExisted && data.TypeID == 4 || isExisted && data.TypeID == 5 ||
                isExisted && data.TypeID == 6)
            {
                TempData["ErrorMessage"] = "Mục " + HomeDao.GetTypeNotice(data.TypeID) + " chỉ được đăng 1 bài viết!";

                return(RedirectToAction("CreateNotification"));
            }

            if (ModelState.IsValid)
            {
                NOTICE_STORE obj = new NOTICE_STORE
                {
                    Title      = data.Title,
                    Content    = data.Content,
                    CreateTime = DateTime.Now,
                    TypeID     = data.TypeID,
                    LibID      = data.LibID
                };
                _dbContext.NOTICE_STORE.Add(obj);
                _dbContext.SaveChanges();
            }

            TempData["SuccessfulMessage"] = "Đăng bài thành công!!";

            return(RedirectToAction("NotificationHome", new { page = 1 }));
        }
コード例 #11
0
        public ActionResult SearchNotification(string searchByTitle, int searchByType, int searchByLibrary,
                                               string startDate, string endDate)
        {
            var noticeListFromDb = _dbContext.NOTICE_STORE.AsQueryable();
            var theStartTime     = ConvertToDate(startDate);
            var theEndTime       = ConvertToDate(endDate);
            //Item1: year, Item2: month, Item3: day
            var    startDateTime = new DateTime(theStartTime.Item1, theStartTime.Item2, theStartTime.Item3);
            var    endDateTime   = new DateTime(theEndTime.Item1, theEndTime.Item2, theEndTime.Item3);
            string title         = Regex.Replace(searchByTitle, @"\s+", " ").Trim();

            if (string.IsNullOrEmpty(title) && searchByLibrary == 0 && searchByType == 0 &&
                CheckNullDateTime(startDateTime) && CheckNullDateTime(endDateTime))
            {
                TempData["SearchNoticeList"] = null;
            }
            else
            {
                if (!string.IsNullOrEmpty(title))
                {
                    noticeListFromDb = noticeListFromDb.Where(t => t.Title.Contains(title) || t.Title.Equals(title));
                }

                if (searchByType != 0)
                {
                    noticeListFromDb = noticeListFromDb.Where(t => t.TypeID == searchByType);
                }

                if (searchByLibrary != 0)
                {
                    noticeListFromDb = noticeListFromDb.Where(t => t.LibID == searchByLibrary);
                }

                if (!CheckNullDateTime(startDateTime) && !CheckNullDateTime(endDateTime))
                {
                    noticeListFromDb = noticeListFromDb.Where(t => t.CreateTime >= startDateTime && t.CreateTime <= endDateTime);
                }

                if (!CheckNullDateTime(startDateTime))
                {
                    noticeListFromDb = noticeListFromDb.Where(t => t.CreateTime >= startDateTime);
                }

                if (!CheckNullDateTime(endDateTime))
                {
                    noticeListFromDb = noticeListFromDb.Where(t => t.CreateTime <= endDateTime);
                }

                var noticeStoreList = noticeListFromDb.OrderByDescending(t => t.CreateTime).ToList();
                var noticeList      = (from t in noticeStoreList
                                       select new Notification()
                {
                    ID = t.ID,
                    Title = t.Title,
                    Content = t.Content,
                    CreateTime = t.CreateTime.ToString("HH:mm:ss dd/MM/yyyy"),
                    TypeName = HomeDao.GetTypeNotice(t.TypeID),
                    LibraryName = HomeDao.GetLibraryCode(t.LibID)
                }).ToList();

                TempData["SearchNoticeList"] = noticeList;
            }

            return(RedirectToAction("NotificationHome", new { page = 1 }));
        }
コード例 #12
0
 public HomeController()
 {
     spmoip = HomeDao.getSPMoi();
     spkhmp = HomeDao.getSPKM();
 }
コード例 #13
0
 public HomeService()
 {
     homeDao = new HomeDao();
 }
コード例 #14
0
 public ServicioHome(AJDESIGNEntities context)
 {
     DaoHome = new HomeDao(context);
 }