Beispiel #1
0
        /// <summary>
        /// 保存账户
        /// </summary>
        /// <param name="info">账户</param>
        /// <returns>主键ID</returns>
        public async Task <ResultInfo <int> > SaveAmountAccountAsync(AmountAccountInfo info)
        {
            //获取原有列表
            var list = await BasicDAL.Inst.QueryAmountAccountAsync(this.LoginInfo.FamilyID);

            //判断名称是否已被使用
            if (list.Exists(m => m.ID != info.ID && m.Name == info.Name))
            {
                return(new ResultInfo <int>(false, this.Res.Bas.NameExisted, -1));
            }

            //尝试查找原数据
            var model = list.Find(m => m.ID == info.ID);

            //新建
            if (model == null)
            {
                model            = new AmountAccount();
                model.FamilyID   = this.LoginInfo.FamilyID;
                model.InitAmount = info.Amount;
                model.Amount     = info.Amount;
            }

            model.Name     = info.Name;
            model.IsActive = info.IsActive;
            model.Remark   = info.Remark;

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

            //保存到数据库
            await BasicDAL.Inst.SaveAmountAccountAsync(model);

            return(new ResultInfo <int>(true, Res.Gen.OK, model.ID));
        }
Beispiel #2
0
        /// <summary>
        /// 获取账户
        /// </summary>
        /// <param name="id">主键ID</param>
        /// <returns></returns>
        public async Task <AmountAccountInfo> GetAmountAccountAsync(int id)
        {
            //获取数据库信息
            var model = await BasicDAL.Inst.GetAmountAccountAsync(this.LoginInfo.FamilyID, id);

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

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

            info.ID       = model.ID;
            info.Name     = model.Name;
            info.Amount   = model.Amount;
            info.IsActive = model.IsActive;
            info.Remark   = model.Remark;

            return(info);
        }
Beispiel #3
0
        public async Task <ResultInfo <int> > SaveAmountAccountAsync([FromBody] AmountAccountInfo info)
        {
            var result = await this.bll.SaveAmountAccountAsync(info);

            return(result);
        }