public JsonResult LoadFields(int isActive)
        {
            //isActive=>Denotes which type of data to get(i.e,active,inactive or all)
            FormsAuthenticationTicket ticket = null;

            try
            {
                _FieldBusinessLogic = new FieldBusinessLogic();
                HttpCookie authCookie = System.Web.HttpContext.Current.Request.Cookies[FormsAuthentication.FormsCookieName];
                ticket = FormsAuthentication.Decrypt(authCookie.Value);

                var FieldArr = _FieldBusinessLogic.GetAllFields(isActive);


                return(Json(FieldArr));
            }
            catch (Exception ex)
            {
                currentFile = this.ControllerContext.RouteData.Values["controller"].ToString(); // System.Diagnostics.StackTrace(true).GetFrame(0).GetFileName();
                StackTrace st = new StackTrace();
                StackFrame sf = st.GetFrame(0);
                methodName = sf.GetMethod().Name;
                ErrorLogHelper.UpdatingErrorLog(currentFile + "-" + methodName, ticket == null ? "N/A" : ticket.Name, ex);
                return(Json(null));
            }
        }
        public JsonResult AddOrUpdateField(Field FieldObj)
        {
            FormsAuthenticationTicket ticket = null;

            try
            {
                _FieldBusinessLogic = new FieldBusinessLogic();
                bool isSuccess = false;
                _UserDetailsBusinessLogic = new UserDetailsBusinessLogic();
                HttpCookie authCookie = System.Web.HttpContext.Current.Request.Cookies[FormsAuthentication.FormsCookieName];
                ticket = FormsAuthentication.Decrypt(authCookie.Value);
                int currentUserId = _UserDetailsBusinessLogic.GetUserID(ticket.Name);


                if (_FieldBusinessLogic.IsFieldAvailable(FieldObj.FieldCode) == true)
                {
                    isSuccess = _FieldBusinessLogic.UpdateField(FieldObj);
                }
                else
                {
                    isSuccess = _FieldBusinessLogic.SaveField(FieldObj, currentUserId);
                }

                return(Json(isSuccess));
            }
            catch (Exception ex)
            {
                currentFile = this.ControllerContext.RouteData.Values["controller"].ToString(); // System.Diagnostics.StackTrace(true).GetFrame(0).GetFileName();
                StackTrace st = new StackTrace();
                StackFrame sf = st.GetFrame(0);
                methodName = sf.GetMethod().Name;
                ErrorLogHelper.UpdatingErrorLog(currentFile + "-" + methodName, ticket == null ? "N/A" : ticket.Name, ex);
                return(Json(false));
            }
        }
        public JsonResult ChangeStatusForAllFields(bool isActiveForAll)
        {
            FormsAuthenticationTicket ticket = null;

            try
            {
                _FieldBusinessLogic = new FieldBusinessLogic();
                HttpCookie authCookie = System.Web.HttpContext.Current.Request.Cookies[FormsAuthentication.FormsCookieName];
                ticket = FormsAuthentication.Decrypt(authCookie.Value);
                bool isSuccess = false;

                isSuccess = _FieldBusinessLogic.ChangeStatusForAllFields(isActiveForAll);

                return(Json(isSuccess));
            }
            catch (Exception ex)
            {
                currentFile = this.ControllerContext.RouteData.Values["controller"].ToString(); // System.Diagnostics.StackTrace(true).GetFrame(0).GetFileName();
                StackTrace st = new StackTrace();
                StackFrame sf = st.GetFrame(0);
                methodName = sf.GetMethod().Name;
                ErrorLogHelper.UpdatingErrorLog(currentFile + "-" + methodName, ticket == null ? "N/A" : ticket.Name, ex);
                return(Json(false));
            }
        }
        public JsonResult GetFieldCodesForAutoComplete(string FieldCode)
        {
            FormsAuthenticationTicket ticket = null;

            try
            {
                _FieldBusinessLogic = new FieldBusinessLogic();
                HttpCookie authCookie = System.Web.HttpContext.Current.Request.Cookies[FormsAuthentication.FormsCookieName];
                ticket = FormsAuthentication.Decrypt(authCookie.Value);

                var FieldArr = _FieldBusinessLogic.GetFieldCodesForAutoComplete(FieldCode);


                return(Json(FieldArr));
            }
            catch (Exception ex)
            {
                currentFile = this.ControllerContext.RouteData.Values["controller"].ToString(); // System.Diagnostics.StackTrace(true).GetFrame(0).GetFileName();
                StackTrace st = new StackTrace();
                StackFrame sf = st.GetFrame(0);
                methodName = sf.GetMethod().Name;
                ErrorLogHelper.UpdatingErrorLog(currentFile + "-" + methodName, ticket == null ? "N/A" : ticket.Name, ex);
                return(Json(false));
            }
        }