Exemple #1
0
        /// <summary>
        /// </summary>
        /// <param name="FnFunc">flag dari method seperti save, edit delete</param>
        /// <param name="ex">Exception yang dikirim dari method jk masuk catch / bisa jg di harcode : new Exception(--string--)</param>
        /// <returns></returns>
        public ApiGridResponse ResCUD(object[] par, string FnFunc, Exception ex)
        {
            ApiGridResponse res = new ApiGridResponse();
            ApiStatus       st  = new ApiStatus();

            if (ex == null)
            {
                res.Header.Status = st.res.Success;
                switch (FnFunc.ToLower())
                {
                case "save":
                    res.Header.Message = st.res.SaveMsg;
                    break;

                case "edit":
                    res.Header.Message = st.res.EditMsg;
                    break;

                case "delete":
                    res.Header.Message = st.res.DeleteMsg;
                    break;
                }
            }
            else
            {
                res.Header.Status  = st.res.Failed;
                res.Header.Message = ex.Message;
            }

            res.Body.Data = par;
            return(res);
        }
        public ApiGridResponse ResGetDataTable(object[] par, Exception ex)
        {
            ApiGridResponse res = new ApiGridResponse();
            ApiStatus       st  = new ApiStatus();

            if (ex == null)
            {
                res.Header.Status  = st.res.Success;
                res.Header.Message = st.res.BindData;
                res.Body.Data      = par;
            }
            else
            {
                res.Header.Status  = st.res.Failed;
                res.Header.Message = ex.Message;
                res.Body.Data      = null;
            }
            return(res);
        }