public ActionResult ForceDelete(int id)
        {
            var model = new FormTemplateModel()
            {
                Id         = id,
                UpdateUid  = User.GetClaimValue(ClaimTypes.PrimarySid),
                UpdateDate = DateTime.Now
            };
            var repository = new FormTemplateRepository();

            return(Json(repository.DeleteFormTemplate(model) ? new { result = "OK" } : new { result = "ERROR" }));
        }
        public ActionResult Approve(int id, bool isApprove, string reason)
        {
            var model = new FormTemplateModel()
            {
                UpdateUid  = User.GetClaimValue(ClaimTypes.PrimarySid),
                UpdateDate = DateTime.Now,
                IsApprove  = isApprove,
                Reason     = reason,
                Id         = id
            };
            var repository = new FormTemplateRepository();

            return(Json(repository.ApproveFormTemplate(model) ? new { result = "OK" } : new { result = "ERROR" }));
        }
        public ActionResult Edit(int id)
        {
            var empId = User.GetClaimValue(ClaimTypes.PrimarySid);

            try
            {
                var repository = new FormTemplateRepository();
                var item       = repository.GetAll(null, null, null, empId, id, null, null).FirstOrDefault();
                return(View(item));
            }
            catch (Exception ex)
            {
                LogHelper.Error("FormTemplateControler GetFormTemplate: " + ex.Message + " Inner Exception: " + ex.InnerException.Message);
                ViewBag.ErrorMessage = "Has something wrong, please contact with admin";
                return(RedirectToAction("Index"));
            }
        }
        public ActionResult ViewDetail(int id)
        {
            var controllerId = this.ControllerContext.RouteData.Values["controller"].ToString() + "Controller";

            ViewBag.Rights = (new AuthorizationRepository()).GetRights(controllerId, User.GetClaimValue(ClaimTypes.Role));

            var empId = User.GetClaimValue(ClaimTypes.PrimarySid);

            try
            {
                var repository = new FormTemplateRepository();
                var item       = repository.GetAll(null, null, null, empId, id, null, null).FirstOrDefault();
                return(View(item));
            }
            catch (Exception ex)
            {
                LogHelper.Error("FormTemplateControler GetFormTemplate: " + ex.Message + " Inner Exception: " + ex.InnerException.Message);
                ViewBag.ErrorMessage = "Has something wrong, please contact with admin";
                return(RedirectToAction("Index"));
            }
        }
        public ActionResult GetAll(string subject, string category, string userId, int id, string dateFrom, string dateTo, string sortdatafield, string sortorder, int pagesize, int pagenum)
        {
            var fromDate = string.IsNullOrEmpty(dateFrom) ? DateTime.MinValue : (new DateTime(int.Parse(dateFrom.Split('.')[0]), int.Parse(dateFrom.Split('.')[1]), int.Parse(dateFrom.Split('.')[2])));
            var toDate   = string.IsNullOrEmpty(dateTo) ? DateTime.MaxValue : ((new DateTime(int.Parse(dateTo.Split('.')[0]), int.Parse(dateTo.Split('.')[1]), int.Parse(dateTo.Split('.')[2]))));

            string empId      = User.GetClaimValue(ClaimTypes.PrimarySid);
            var    repository = new FormTemplateRepository();
            var    list       = repository.GetAll(string.IsNullOrEmpty(subject) ? null : subject, string.IsNullOrEmpty(category) ? null : category, string.IsNullOrEmpty(userId) ? null : userId, empId, id, fromDate, toDate);
            var    total      = list.Count();

            if (!string.IsNullOrEmpty(sortorder))
            {
                list = sortorder == "asc" ? list.OrderBy(o => o.GetType().GetProperty(sortdatafield).GetValue(o, null)) :
                       list.OrderByDescending(o => o.GetType().GetProperty(sortdatafield).GetValue(o, null));
            }
            list = list.Skip(pagesize * pagenum).Take(pagesize);
            var result = new
            {
                TotalRows = total,
                Rows      = list
            };

            return(Json(result, JsonRequestBehavior.AllowGet));
        }
        public ActionResult PinFormTemplate(int id, bool pin)
        {
            var repository = new FormTemplateRepository();

            return(Json(repository.UpdatePin(id, pin) ? new { result = "OK" } : new { result = "ERROR" }));
        }
        public ActionResult Submit(int id, bool status)
        {
            var repository = new FormTemplateRepository();

            return(Json(repository.SubmitForm(id, status) ? new { result = "OK" } : new { result = "ERROR" }));
        }