Пример #1
0
        //[Authorize(AuthenticationSchemes = "jwt")]
        public APIResult AddInvoiceTitleTest([FromBody] InvoiceTitleModel input)
        {
            //input.MemberId = GetMemberId();
            input.MemberId = 87;
            if (!(input.BuyerNumber.Length >= 15 && input.BuyerNumber.Length <= 20))
            {
                return(Error("税号格式错误,税号由15位、18或者20位码(字符型)组成"));
            }

            if (input.Tel != null && !string.IsNullOrWhiteSpace(input.Tel))
            {
                if (!ValidateUtil.IsValidPhoneAndMobile(input.Tel))
                {
                    return(Error("电话号码格式错误"));
                }
            }
            //if (input.BankAccount != null && !string.IsNullOrWhiteSpace(input.BankAccount))
            //{
            //    if (!ValidateUtil.IsValidAccountNumber(input.BankAccount))
            //    {
            //        return Error("银行卡号格式错误");
            //    }
            //}

            var memberInvoiceTitle = _mapper.Map <MemberInvoiceTitle>(input);

            memberInvoiceTitle.Type = InvoiceType.增值税普通发票;
            db.MemberInvoiceTitle.Add(memberInvoiceTitle);
            db.SaveChanges();

            return(Success(memberInvoiceTitle));
        }
Пример #2
0
        public APIResult DelInvoiceTitle([FromBody] InvoiceTitleModel input)
        {
            var memberId  = GetMemberId();
            var titleData = db.MemberInvoiceTitle.Find(input.Id);

            if (titleData == null || titleData.IsDel || titleData.MemberId != memberId)
            {
                return(Error("记录不存在"));
            }
            titleData.IsDel = true;
            db.SaveChanges();
            return(Success("删除成功"));
        }
Пример #3
0
        public APIResult GetInvoiceTitleById([FromBody] InvoiceTitleModel input)
        {
            //var memberId = GetMemberId();
            //var memberId = 87;

            var titleData = db.MemberInvoiceTitle.Find(input.Id);

            if (titleData == null || titleData.IsDel)
            {
                return(Error("记录不存在"));
            }

            return(Success(_mapper.Map <InvoiceTitleModel>(titleData)));
        }
Пример #4
0
        public APIResult EdityInvoiceTitle([FromBody] InvoiceTitleModel input)
        {
            var memberId  = GetMemberId();
            var titleData = db.MemberInvoiceTitle.Find(input.Id);

            if (titleData == null || titleData.IsDel || titleData.MemberId != memberId)
            {
                return(Error("记录不存在"));
            }
            titleData.MemberInvoiceTitleName = input.MemberInvoiceTitleName;
            titleData.Tel               = input.Tel;
            titleData.BuyerNumber       = input.BuyerNumber;
            titleData.EnterpriseAddress = input.EnterpriseAddress;
            titleData.BankDeposit       = input.BankDeposit;
            titleData.BankAccount       = input.BankAccount;
            db.SaveChanges();
            return(Success(_mapper.Map <InvoiceTitleModel>(titleData)));
        }