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));
        }