Ejemplo n.º 1
0
        public IHttpActionResult Post(CHARGEGROUP baseRequest)
        {
            baseRequest.NSID = SecurityHelper.CurrentPrincipal.OrgId;
            var response = service.SavePacMaintain(baseRequest);

            return(Ok(response));
        }
Ejemplo n.º 2
0
        public BaseResponse <CHARGEGROUP> SavePacMaintain(CHARGEGROUP request)
        {
            var response       = new BaseResponse <CHARGEGROUP>();
            var chargeItemList = request.CHARGEITEM;

            request.CHARGEITEM = null;
            if (string.IsNullOrEmpty(request.CHARGEGROUPID))
            {
                request.CHARGEGROUPID = base.GenerateCode(SecurityHelper.CurrentPrincipal.OrgId, EnumCodeKey.ChargeGroupNo);
                request.CREATEBY      = SecurityHelper.CurrentPrincipal.EmpName;
                request.CREATETIME    = DateTime.Now;
                request.UPDATEBY      = SecurityHelper.CurrentPrincipal.EmpName;
                request.UPDATETIME    = DateTime.Now;
                request.ISDELETE      = false;
            }
            else
            {
                request.UPDATEBY   = SecurityHelper.CurrentPrincipal.EmpName;
                request.UPDATETIME = DateTime.Now;
            }
            unitOfWork.BeginTransaction();
            response = base.Save <LTC_CHARGEGROUP, CHARGEGROUP>(request, (q) => q.CHARGEGROUPID == request.CHARGEGROUPID);
            chargeItemList.ForEach((p) =>
            {
                p.CHARGEGROUPID = response.Data.CHARGEGROUPID;
                if (p.CGCIID == 0 || p.CGCIID == null)
                {
                    p.CREATEBY   = SecurityHelper.CurrentPrincipal.EmpName;
                    p.CREATETIME = DateTime.Now;
                    p.UPDATEBY   = SecurityHelper.CurrentPrincipal.EmpName;
                    p.UPDATETIME = DateTime.Now;
                    p.ISDELETE   = false;
                }
                else
                {
                    p.UPDATEBY   = SecurityHelper.CurrentPrincipal.EmpName;
                    p.UPDATETIME = DateTime.Now;
                }
                base.Save <LTC_CHARGEGROUP_CHARGEITEM, CHARGEITEM>(p, (q) => p.CGCIID == q.CGCIID);
            });
            unitOfWork.Commit();
            return(response);
        }