public HttpResponseMessage FindByRouteCode()
        {
            bal = new M_SectionBAL();
            ResposeType         response   = new ResposeType();
            HttpResponseMessage mapMessage = null;

            M_SectionDTO dto = null;

            response.statusCode = false;
            try
            {
                var context = HttpContext.Current;

                dto = ConvertX.GetReqeustForm <M_SectionDTO>();

                logger.debug("FindByRouteCode dto:" + dto.ToString());
                M_SectionDTO obj = bal.FinByRouteCodeName(dto);
                response.statusCode = true;
                response.data       = obj;
            }
            catch (Exception ex)
            {
                logger.error("FindByRouteCode error:" + ex.ToString());
                response.statusText = ex.ToString();
            }

            mapMessage = Request.CreateResponse(HttpStatusCode.OK, response);
            return(mapMessage);
        }
        public HttpResponseMessage Add()
        {
            bal = new M_SectionBAL();
            ResposeType         response   = new ResposeType();
            HttpResponseMessage mapMessage = null;

            M_SectionDTO dto = null;

            response.statusCode = false;
            try
            {
                var context = HttpContext.Current;

                dto = ConvertX.GetReqeustForm <M_SectionDTO>();
                string UserID = context.Request.Form["UserID"];
                if (ObjUtil.isEmpty(UserID))
                {
                    throw new Exception("UserID is require");
                }
                dto.CreateBy = UserID;
                dto.UpdateBy = UserID;

                logger.debug("Add dto:" + dto.ToString());
                response.statusCode = bal.Add(dto);
            }
            catch (Exception ex)
            {
                logger.error("Add error:" + ex.ToString());
                response.statusText = ex.ToString();
            }

            mapMessage = Request.CreateResponse(HttpStatusCode.OK, response);
            return(mapMessage);
        }
        public HttpResponseMessage LoadList()
        {
            bal = new M_SectionBAL();
            ResposeType         response   = new ResposeType();
            HttpResponseMessage mapMessage = null;
            List <M_SectionDTO> dataList   = new List <M_SectionDTO>();

            M_SectionDTO dto = null;

            response.statusCode = false;
            try
            {
                var context = HttpContext.Current;

                dto = ConvertX.GetReqeustForm <M_SectionDTO>();

                logger.debug("Search dto:" + dto.ToString());
                dataList            = bal.FindByObjList(dto);
                response.statusCode = true;
                response.data       = dataList;
            }
            catch (Exception ex)
            {
                logger.error("Search error:" + ex.ToString());
                response.statusText = ex.ToString();
            }

            mapMessage = Request.CreateResponse(HttpStatusCode.OK, response);
            return(mapMessage);
        }
Exemple #4
0
        public M_SectionDTO FindByRouteCode(object data)
        {
            List <SqlParameter> parameterList = new List <SqlParameter>();

            objList   = new List <M_SectionDTO>();
            dataTable = null;

            string procName = "sp_M_Section_FindByRouteCode";

            try
            {
                dataTable = new DataTable();
                adapter   = new SqlDataAdapter();
                SqlConnection conn = OpenConnection();
                if (data != null)
                {
                    parameterList.AddRange(GetParameters(procName, data).ToArray());
                }
                command             = new SqlCommand(procName, conn);
                command.CommandType = CommandType.StoredProcedure;
                if (data != null)
                {
                    command.Parameters.AddRange(parameterList.ToArray());
                }



                using (SqlDataReader reader = command.ExecuteReader())
                {
                    obj = ConvertX.GetListFromDataReader <M_SectionDTO>(reader).ToList().FirstOrDefault();
                }
            }
            catch (Exception ex) { }
            finally
            {
                CloseConnection();
            }
            return(obj);
        }