public ActionResult Create(FormCollection fc, CMS_Notifications obj)
 {
     try
     {
         if (ModelState.IsValid)
         {
             CMS_Notifications_DAO objDAO     = new CMS_Notifications_DAO();
             CSF_Users_DAO         objUserDao = new CSF_Users_DAO();
             int userID = objUserDao.GetUserIDByUserName(HttpContext.User.Identity.Name);
             obj.UserCreate = userID;
             int ReturnID = objDAO.Insert(obj);
             if (ReturnID > 0)
             {
                 //cache lai thong bao
                 WebApp.Controllers.HomeController hController = new WebApp.Controllers.HomeController();
                 hController.Cache_ThongBao();
                 SetAlert("Thêm thông báo nội bộ thành công", AlertType.Success);
                 return(RedirectToAction("Index", "CMS_Notifications"));
             }
             else
             {
                 ModelState.AddModelError("", "Thêm thông báo nội bộ không thành công");
             }
             return(View("Index"));
         }
         return(View());
     }
     catch (Exception ex)
     {
         SetAlert("Lỗi" + ex.Message.ToString(), AlertType.Error);
         Logs.WriteLog(ex);
         return(View());
     }
 }
 public ActionResult Edit(FormCollection fc, CMS_Documents obj)
 {
     try
     {
         if (ModelState.IsValid)
         {
             CMS_Documents_DAO objDAO     = new CMS_Documents_DAO();
             CSF_Users_DAO     objUserDao = new CSF_Users_DAO();
             if (objDAO.CheckExist_DocumentNumber(obj))
             {
                 SetAlert("Số hiệu đã tồn tại!", AlertType.Error);
                 return(View());
             }
             if (objDAO.Update(obj))
             {
                 //cache lai van ban
                 WebApp.Controllers.HomeController hController = new WebApp.Controllers.HomeController();
                 hController.Cache_VanBan();
                 SetAlert("Cập nhật văn bản thành công", AlertType.Success);
                 return(RedirectToAction("Index", "CMS_Documents"));
             }
             else
             {
                 SetAlert("Cập nhật không thành công", AlertType.Error);
             }
         }
         return(View(obj));
     }
     catch (Exception ex)
     {
         SetAlert("Lỗi" + ex.Message.ToString(), AlertType.Error);
         Logs.WriteLog(ex);
         return(View());
     }
 }
 public ActionResult Edit(FormCollection fc, CMS_Notifications obj)
 {
     try
     {
         if (ModelState.IsValid)
         {
             CMS_Notifications_DAO objDAO = new CMS_Notifications_DAO();
             if (objDAO.Update(obj))
             {
                 //cache lai thong bao
                 WebApp.Controllers.HomeController hController = new WebApp.Controllers.HomeController();
                 hController.Cache_ThongBao();
                 SetAlert("Cập nhật thông báo nội bộ thành công", AlertType.Success);
                 return(RedirectToAction("Index", "CMS_Notifications"));
             }
             else
             {
                 SetAlert("Cập nhật thông báo nội bộ không thành công", AlertType.Error);
             }
         }
         return(View(obj));
     }
     catch (Exception ex)
     {
         SetAlert("Lỗi" + ex.Message.ToString(), AlertType.Error);
         Logs.WriteLog(ex);
         return(View());
     }
 }
 public JsonResult SetCongBo(string[] arrChecked, string[] checkedTieuDiem)
 {
     try
     {
         int              ikq                 = 0;
         string[]         arrIDTinTuc         = arrChecked;
         string[]         arrIDTinTucTieuDiem = checkedTieuDiem;
         CMS_News_DAO     objNewsDao          = new CMS_News_DAO();
         CMS_Approves_DAO objApproverDao      = new CMS_Approves_DAO();
         CMS_Approves     objApp              = new CMS_Approves();
         int              iIDNews             = 0;
         //int intRoleID = Convert.ToInt32(RoleID);
         //int intUserID = 0;
         //CSF_UserRole_DAO objUserRoleDAO = new CSF_UserRole_DAO();
         if (arrIDTinTuc != null && arrIDTinTuc.Length > 0)
         {
             for (int i = 0; i < arrIDTinTuc.Length; i++)
             {
                 Int16 iTieuDiem = 0;
                 if (arrIDTinTucTieuDiem != null && arrIDTinTucTieuDiem.Length > 0)
                 {
                     for (int j = 0; j < arrIDTinTucTieuDiem.Length; j++)
                     {
                         if (arrIDTinTuc[i].ToString() == arrIDTinTucTieuDiem[j].ToString())
                         {
                             iTieuDiem = 1;
                             break;
                         }
                     }
                 }
                 iIDNews = Convert.ToInt32(arrIDTinTuc[i].ToString());
                 objNewsDao.UpdateTrangThai(iIDNews, 5, iTieuDiem);
                 ikq = 1;
             }
         }
         if (ikq > 0)
         {
             //cache lai tin bai
             WebApp.Controllers.HomeController hController = new WebApp.Controllers.HomeController();
             hController.Cache_TinBai();
             return(Json(new { status = true, message = "Công bố tin tức thành công" }, JsonRequestBehavior.AllowGet));
         }
         else
         {
             return(Json(new { status = false, message = "Lỗi công bố tin tức" }, JsonRequestBehavior.AllowGet));
         }
     }
     catch (Exception ex)
     {
         Logs.WriteLog(ex);
         return(Json(new { status = false, message = "Lỗi: " + ex }, JsonRequestBehavior.AllowGet));
     }
 }
 public ActionResult Detail(int id)
 {
     try
     {
         DT_WebGISEntities entity = new DT_WebGISEntities();
         WebApp.Controllers.HomeController homeController = new WebApp.Controllers.HomeController();
         var tb = homeController.GetCacheThongBao().Where(x => x.ID == id).FirstOrDefault();
         return(View(tb));
     }
     catch (Exception ex)
     {
         SetAlert("Lỗi" + ex.Message.ToString(), AlertType.Error);
         Logs.WriteLog(ex);
         return(View());
     }
 }
Exemple #6
0
        public void ErrorTest()
        {
            // Arrange
            var controller = new WebApp.Controllers.HomeController();

            // Act
            var result = controller.Error() as ViewResult;

            // Assert
            Assert.NotNull(result);
            Assert.Null(result.Model);
            Assert.Null(result.ContentType);
            Assert.Null(result.TempData);
            Assert.Null(result.ViewEngine);
            Assert.Null(result.ViewName);
            Assert.NotNull(result.ViewData);
            Assert.Empty(result.ViewData);
        }
 public JsonResult SetNgungCongBo(string[] arrChecked, string abc)
 {
     try
     {
         int              ikq            = 0;
         string[]         arrIDTinTuc    = arrChecked;
         CMS_News_DAO     objNewsDao     = new CMS_News_DAO();
         CMS_Approves_DAO objApproverDao = new CMS_Approves_DAO();
         CMS_Approves     objApp         = new CMS_Approves();
         int              iIDNews        = 0;
         if (arrIDTinTuc != null && arrIDTinTuc.Length > 0)
         {
             for (int i = 0; i < arrIDTinTuc.Length; i++)
             {
                 iIDNews = Convert.ToInt32(arrIDTinTuc[i].ToString());
                 objNewsDao.UpdateTrangThai(iIDNews, 6, 0);
                 objApp.ID_News        = iIDNews;
                 objApp.ID_News_Status = 6;
                 CSF_Users_DAO objUserDao = new CSF_Users_DAO();
                 int           intUserID  = objUserDao.GetUserIDByUserName(HttpContext.User.Identity.Name);
                 objApp.ID_User = intUserID;
                 objApp.Comment = abc;
                 ikq            = objApproverDao.Insert(objApp);
             }
         }
         if (ikq > 0)
         {
             //cache lai tin bai
             WebApp.Controllers.HomeController hController = new WebApp.Controllers.HomeController();
             hController.Cache_TinBai();
             return(Json(new { status = true, message = "Ngừng công bố tin tức thành công" }, JsonRequestBehavior.AllowGet));
         }
         else
         {
             return(Json(new { status = false, message = "Lỗi ngừng công bố tin tức" }, JsonRequestBehavior.AllowGet));
         }
     }
     catch (Exception ex)
     {
         Logs.WriteLog(ex);
         return(Json(new { status = false, message = "Lỗi: " + ex }, JsonRequestBehavior.AllowGet));
     }
 }
 public ActionResult Create(FormCollection fc, CMS_Documents obj)
 {
     try
     {
         TempData.Keep("TypeOfDocumentID");
         TempData.Keep("AreaOfDocument");
         TempData.Keep("OrganizationID");
         if (ModelState.IsValid)
         {
             CMS_Documents_DAO objDAO = new CMS_Documents_DAO();
             if (objDAO.CheckExist_DocumentNumber(obj))
             {
                 SetAlert("Số hiệu đã tồn tại!", AlertType.Error);
                 return(View());
             }
             CSF_Users_DAO objUserDao = new CSF_Users_DAO();
             int           intUserID  = objUserDao.GetUserIDByUserName(HttpContext.User.Identity.Name);
             obj.UserCreate = intUserID;
             int ReturnID = objDAO.Insert(obj);
             if (ReturnID > 0)
             {
                 //cache lai van ban
                 WebApp.Controllers.HomeController hController = new WebApp.Controllers.HomeController();
                 hController.Cache_VanBan();
                 SetAlert("Thêm văn bản thành công", AlertType.Success);
                 return(RedirectToAction("index", "cms_documents"));
             }
             else
             {
                 ModelState.AddModelError("", "Thêm văn bản không thành công");
             }
             return(View("Index"));
         }
         return(View());
     }
     catch (Exception ex)
     {
         SetAlert("Lỗi" + ex.Message.ToString(), AlertType.Error);
         Logs.WriteLog(ex);
         return(View());
     }
 }
Exemple #9
0
        public void ContactTest()
        {
            // Arrange
            var controller = new WebApp.Controllers.HomeController();

            // Act
            var result = controller.Contact() as ViewResult;

            // Assert
            Assert.NotNull(result);
            Assert.Null(result.Model);
            Assert.Null(result.ContentType);
            Assert.Null(result.TempData);
            Assert.Null(result.ViewEngine);
            Assert.Null(result.ViewName);
            Assert.NotNull(result.ViewData);
            Assert.NotEmpty(result.ViewData);
            Assert.Equal(1, result.ViewData.Count);
            Assert.Equal("Your contact page.", result.ViewData["Message"]);
        }
 public JsonResult Delete(int id)
 {
     try
     {
         CMS_Documents_DAO objDAO = new CMS_Documents_DAO();
         if (objDAO.Delete(id))
         {
             //cache lai van ban
             WebApp.Controllers.HomeController hController = new WebApp.Controllers.HomeController();
             hController.Cache_VanBan();
             SetAlert("Xóa văn bản thành công", AlertType.Success);
             return(Json(new { status = true, message = "" }, JsonRequestBehavior.AllowGet));
         }
         else
         {
             return(Json(new { status = false, message = "Lỗi xóa văn bản" }, JsonRequestBehavior.AllowGet));
         }
     }
     catch (Exception ex)
     {
         Logs.WriteLog(ex);
         return(Json(new { status = false, message = "Lỗi: " + ex }, JsonRequestBehavior.AllowGet));
     }
 }
 public JsonResult Delete(int id)
 {
     try
     {
         CMS_Notifications_DAO objDAO = new CMS_Notifications_DAO();
         if (objDAO.Delete(id))
         {
             // cache lai thong bao
             WebApp.Controllers.HomeController hController = new WebApp.Controllers.HomeController();
             hController.Cache_ThongBao();
             SetAlert("Xóa thông báo nội bộ thành công", AlertType.Success);
             return(Json(new { status = true, message = "" }, JsonRequestBehavior.AllowGet));
         }
         else
         {
             return(Json(new { status = false, message = "Lỗi xóa thông báo nội bộ" }, JsonRequestBehavior.AllowGet));
         }
     }
     catch (Exception ex)
     {
         Logs.WriteLog(ex);
         return(Json(new { status = false, message = "Lỗi: " + ex }, JsonRequestBehavior.AllowGet));
     }
 }