Пример #1
0
        /// <summary>
        /// 保存借还信息
        /// </summary>
        /// <param name="info">借还信息</param>
        /// <returns>主键ID</returns>
        public async Task <ResultInfo <int> > SaveBorrowRepayAsync(BorrowRepayInfo info)
        {
            //对方名称不能为空
            if (string.IsNullOrWhiteSpace(info.Target))
            {
                return(new ResultInfo <int>(false, this.Res.IO.BRTargetEmpty, -1));
            }

            //判断借还类型是否存在
            if (Enum.IsDefined(typeof(EnmBorrowRepayType), info.BRType) == false)
            {
                return(new ResultInfo <int>(false, this.Res.Bas.BorrowRepayTypeUnexist, -1));
            }

            //判断账户是否存在
            var modelAmountAccount = await BasicDAL.Inst.GetAmountAccountAsync(this.LoginInfo.FamilyID, info.AmountAccountID);

            if (modelAmountAccount == null)
            {
                return(new ResultInfo <int>(false, this.Res.Bas.AmountAccountUnexist, -1));
            }

            //转成model
            var model = new BorrowRepay();

            model.ID              = info.ID;
            model.FamilyID        = this.LoginInfo.FamilyID;
            model.BRDate          = info.BRDate;
            model.Target          = info.Target;
            model.BRType          = info.BRType;
            model.AmountAccountID = info.AmountAccountID;
            model.Amount          = info.Amount;
            model.Remark          = info.Remark;

            //设置创建者/更新者字段值
            this.SetCreateUpdateFields(model);

            //保存到数据库
            var ret = await CacheLock.DoByLockFamilyAsync(this.LoginInfo.FamilyID, () => InOutDAL.Inst.SaveBorrowRepayAsync(model));

            if (!ret.IsDone)
            {
                return(new ResultInfo <int>(false, Res.Gen.WaiteTimeOut, model.ID));
            }

            return(new ResultInfo <int>(true, Res.Gen.OK, model.ID));
        }
Пример #2
0
        /// <summary>
        /// 获取借还信息
        /// </summary>
        /// <param name="id">主键ID</param>
        /// <returns></returns>
        public async Task <BorrowRepayInfo> GetBorrowRepayAsync(int id)
        {
            //获取数据库信息
            var model = await InOutDAL.Inst.GetBorrowRepayAsync(this.LoginInfo.FamilyID, id);

            if (model == null)
            {
                return(null);
            }

            //结果
            var info = new BorrowRepayInfo();

            info.ID              = model.ID;
            info.BRDate          = model.BRDate;
            info.Target          = model.Target;
            info.BRType          = model.BRType;
            info.AmountAccountID = model.AmountAccountID;
            info.Amount          = model.Amount;
            info.Remark          = model.Remark;

            return(info);
        }
Пример #3
0
        public async Task <ResultInfo <int> > SaveBorrowRepayAsync([FromBody] BorrowRepayInfo info)
        {
            var result = await this.bll.SaveBorrowRepayAsync(info);

            return(result);
        }