Exemple #1
0
        //===================================== Add Brand =====================================//
        static public SportModels.ResponseModel Api_Sport_Brand_Add_BLL(SportModels.BrandModel BM)
        {
            SportModels.ResponseModel RM = new SportModels.ResponseModel();

            try
            {
                //lay du lieu tu DAL, return
                SportModels.DALOutput DALO = new SportModels.DALOutput();

                DALO = CSqlSport.Api_Sport_Brand_Add_DAL(BM);

                // response info (success)
                RM.Code    = DALO.ErrorCode;
                RM.Message = DALO.ErrorMessage;
                RM.Data    = DALO.SqlData;
            }
            catch (Exception ex)
            {
                // log error
                CLog.LogError(CBase.GetDeepCaller(), CBase.GetDetailError(ex));
                // response info (error)
                RM.Code    = CBase.GetLayerErrorCode(CBase.LAYER.BLL);
                RM.Message = ex.Message;
                RM.Data    = null;
            }

            // return
            return(RM);
        }
Exemple #2
0
        //===================================== Delete Category =====================================//
        public static SportModels.DALOutput Api_Sport_Category_Delete_DAL(SportModels.CategoryModel CM)
        {
            DataSet ds = new DataSet();

            try
            {
                SqlParameter[] arrParams = new SqlParameter[1];

                // input params
                arrParams[0]           = new SqlParameter("categoryID", SqlDbType.Int);
                arrParams[0].Direction = ParameterDirection.Input;
                arrParams[0].Value     = CM.CategoryID;

                // exec
                ds = SqlHelper.ExecuteDataset(CConfigDS.CONNECTION_STRING_SQL_SPORT_SHOP, CommandType.StoredProcedure, CConfigDS.SPORT_SHOP_SQL_SP_CATEGORY_DELETE, arrParams);

                // return (neu sp ko tra error code,msg thi tu gan default)
                return(new SportModels.DALOutput()
                {
                    ErrorCode = CConfigDS.RESPONSE_CODE_SUCCESS, ErrorMessage = CConfigDS.RESPONSE_MSG_SUCCESS, SqlData = ds
                });
            }
            catch (Exception ex)
            {
                // log error
                CLog.LogError(CBase.GetDeepCaller(), CBase.GetDetailError(ex));
                // error => return null
                return(new SportModels.DALOutput()
                {
                    ErrorCode = CBase.GetLayerErrorCode(CBase.LAYER.DAL), ErrorMessage = ex.Message, SqlData = null
                });
            }
        }
Exemple #3
0
        //===================================== Add Brand =====================================//
        public static SportModels.DALOutput Api_Sport_Brand_Add_DAL(SportModels.BrandModel BM)
        {
            DataSet ds = new DataSet();

            try
            {
                SqlParameter[] arrParams = new SqlParameter[3];

                // input params
                arrParams[0]           = new SqlParameter("brandName", SqlDbType.NVarChar, 50);
                arrParams[0].Direction = ParameterDirection.Input;
                arrParams[0].Value     = BM.BrandName;

                // input params
                arrParams[1]           = new SqlParameter("brandURL", SqlDbType.NVarChar, 200);
                arrParams[1].Direction = ParameterDirection.Input;
                arrParams[1].Value     = BM.BrandURL;

                // input params
                arrParams[2]           = new SqlParameter("createdDate", SqlDbType.Date);
                arrParams[2].Direction = ParameterDirection.Input;
                arrParams[2].Value     = BM.CreatedDate;

                // exec
                ds = SqlHelper.ExecuteDataset(CConfigDS.CONNECTION_STRING_SQL_SPORT_SHOP, CommandType.StoredProcedure, CConfigDS.SPORT_SHOP_SQL_SP_BRAND_ADD, arrParams);

                // return (neu sp ko tra error code,msg thi tu gan default)
                return(new SportModels.DALOutput()
                {
                    ErrorCode = CConfigDS.RESPONSE_CODE_SUCCESS, ErrorMessage = CConfigDS.RESPONSE_MSG_SUCCESS, SqlData = ds
                });
            }
            catch (Exception ex)
            {
                // log error
                CLog.LogError(CBase.GetDeepCaller(), CBase.GetDetailError(ex));
                // error => return null
                return(new SportModels.DALOutput()
                {
                    ErrorCode = CBase.GetLayerErrorCode(CBase.LAYER.DAL), ErrorMessage = ex.Message, SqlData = null
                });
            }
        }