示例#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>
        public async Task <ResultInfo <bool> > DeleteBorrowRepayAsync(int id)
        {
            //从数据库删除
            var ret = await CacheLock.DoByLockFamilyAsync(this.LoginInfo.FamilyID, () => InOutDAL.Inst.DeleteBorrowRepayAsync(this.LoginInfo.FamilyID, id));

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

            if (ret.Result)
            {
                return(new ResultInfo <bool>(true, Res.Gen.OK, true));
            }
            else
            {
                return(new ResultInfo <bool>(false, this.Res.Gen.NoRight, false));
            }
        }
示例#3
0
        /// <summary>
        /// 保存收入信息
        /// </summary>
        /// <param name="info">收入信息</param>
        /// <returns>主键ID</returns>
        public async Task <ResultInfo <int> > SaveInComeAsync(InComeInfo info)
        {
            //判断收入类型是否存在
            var modelInType = await BasicDAL.Inst.GetInTypeAsync(this.LoginInfo.FamilyID, info.InTypeID);

            if (modelInType == null)
            {
                return(new ResultInfo <int>(false, this.Res.Bas.InTypeUnexist, -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 InCome();

            model.ID              = info.ID;
            model.FamilyID        = this.LoginInfo.FamilyID;
            model.InDate          = info.InDate;
            model.InTypeID        = info.InTypeID;
            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.SaveInComeAsync(model));

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

            return(new ResultInfo <int>(true, Res.Gen.OK, model.ID));
        }