Ejemplo n.º 1
0
        public HttpResponseMessage Add()
        {
            bal = new M_MAOPBAL();
            ResposeType         response   = new ResposeType();
            HttpResponseMessage mapMessage = null;

            M_MAOPDTO dto = null;

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

                dto = ConvertX.GetReqeustForm <M_MAOPDTO>();
                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);
        }
Ejemplo n.º 2
0
        public HttpResponseMessage LoadList()
        {
            bal = new M_MAOPBAL();
            ResposeType         response   = new ResposeType();
            HttpResponseMessage mapMessage = null;
            List <M_MAOPDTO>    dataList   = new List <M_MAOPDTO>();

            M_MAOPDTO dto = null;

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

                dto = ConvertX.GetReqeustForm <M_MAOPDTO>();

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