예제 #1
0
        public async Task <ActionResultDto> Execute(ContextDto context)
        {
            try
            {
                init();
                validate();

                var biz = new GetChiTietByIdBiz(context);
                biz.PHIEUBAOHANHCHITIET_ID = _ChiTietId;
                biz.LOGIN_ID = _LoginId;

                var result = await biz.Execute();

                if (string.IsNullOrEmpty(biz.MESSAGE) == false)
                {
                    throw new BaseException(biz.MESSAGE.Split('|')[2]);
                }

                dynamic _metaData = new System.Dynamic.ExpandoObject();

                return(ActionHelper.returnActionResult(HttpStatusCode.OK, result, _metaData));
            }
            catch (BaseException ex)
            {
                return(ActionHelper.returnActionError(HttpStatusCode.BadRequest, ex.Message));
            }
            catch (Exception ex)
            {
                return(ActionHelper.returnActionError(HttpStatusCode.InternalServerError, ex.InnerException != null ? ex.InnerException.Message : ex.Message));
            }
        }
예제 #2
0
        public async Task <ActionResultDto> Execute(ContextDto context)
        {
            try
            {
                init();
                validate();

                var orderClause = sortName + " " + sortDir;
                var total       = 0;

                var biz = new GetChiTietByIdBiz(context);
                biz.PHIEU_CONG_TAC = phieuCongTacIds;
                biz.ORDER_CLAUSE   = orderClause;
                biz.SKIP           = _start;
                biz.TAKE           = _length;

                IEnumerable <dynamic> list = await biz.Execute();

                if (list.Count() > 0)
                {
                    var obj = list.FirstOrDefault();

                    total = Protector.Int(obj.MAXCNT);
                }

                dynamic _metaData = new System.Dynamic.ExpandoObject();
                _metaData.draw  = _draw;
                _metaData.total = total;

                return(ActionHelper.returnActionResult(HttpStatusCode.OK, list, _metaData));
            }
            catch (FormatException ex)
            {
                return(ActionHelper.returnActionError(HttpStatusCode.BadRequest, ex.InnerException != null ? ex.InnerException.Message : ex.Message));
            }
            catch (Exception ex)
            {
                return(ActionHelper.returnActionError(HttpStatusCode.InternalServerError, ex.InnerException != null ? ex.InnerException.Message : ex.Message));
            }
        }