Ejemplo n.º 1
0
        public async Task <bool> DeletePaymentAsync(int id)
        {
            var entity = new JdCat.Cat.Model.Data.PaymentType {
                ID = id
            };

            Context.Attach(entity);
            entity.Status = EntityStatus.Deleted;
            return(await Context.SaveChangesAsync() > 0);
        }
Ejemplo n.º 2
0
        public async Task <bool> SetPaymentSortAsync(JdCat.Cat.Model.Data.PaymentType payment)
        {
            var entity = new JdCat.Cat.Model.Data.PaymentType {
                ID = payment.ID
            };

            Context.Attach(entity);
            entity.Sort = payment.Sort;
            return(await Context.SaveChangesAsync() > 0);
        }
Ejemplo n.º 3
0
        public async Task <JdCat.Cat.Model.Data.PaymentType> AddPaymentAsync(JdCat.Cat.Model.Data.PaymentType payment)
        {
            payment.Category = PaymentCategory.Other;
            var lastEntity = await Context.PaymentTypes
                             .OrderBy(a => a.Sort)
                             .LastOrDefaultAsync(a => a.BusinessId == payment.BusinessId);

            payment.Sort   = (lastEntity?.Sort ?? 0) + 1;
            payment.Status = EntityStatus.Normal;
            Context.Add(payment);
            await Context.SaveChangesAsync();

            return(payment);
        }
Ejemplo n.º 4
0
        public async Task <IActionResult> AddPayment([FromBody] JdCat.Cat.Model.Data.PaymentType payment)
        {
            if (await Service.IsExistPaymentAsync(payment))
            {
                return(Json(new JsonData {
                    Msg = $"已存在名为[{payment.Name}]的支付方式"
                }));
            }
            payment.BusinessId = Business.ID;
            await Service.AddPaymentAsync(payment);

            return(Json(new JsonData {
                Success = true, Msg = "新增成功", Data = payment
            }));
        }
Ejemplo n.º 5
0
        public async Task <bool> IsExistPaymentAsync(JdCat.Cat.Model.Data.PaymentType payment)
        {
            var name = payment.Name.ToLower();

            return(await Context.PaymentTypes.CountAsync(a => a.Status == EntityStatus.Normal && a.BusinessId == payment.BusinessId && a.Name.ToLower() == name) > 0);
        }