コード例 #1
0
        public async Task <IActionResult> PutBankAccount(int id, BankAccount bankAccount)
        {
            if (id != bankAccount.BankAccountID)
            {
                return(BadRequest());
            }

            _context.Entry(bankAccount).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!BankAccountExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
コード例 #2
0
        public async Task <ActionResult> Post(string user)
        {
            var userModel = JsonConvert.DeserializeObject <List <UserModel> >(user);

            CardNumberGenerator numberGenerator = new CardNumberGenerator();
            Int32 cvc        = numberGenerator.RandomNumber(100, 999);
            Int32 cardNumber = numberGenerator.RandomNumber(100000000, 999999999);

            foreach (var item in userModel)
            {
                User newUser = new User();
                newUser.IDcardFincode = item.IDCardFinCode;
                newUser.Email         = item.Email;
                newUser.Name          = item.Name;
                newUser.Surname       = item.Surname;
                newUser.Number        = item.Number;
                newUser.IDCardNumber  = item.IDCardNumber;
                _dbContext.Users.Add(newUser);

                Card card = new Card();
                card.UserId      = newUser.ID;
                card.CVC         = cvc;
                card.CardNumber  = cardNumber.ToString();
                card.CreatedDate = DateTime.Now;
                card.Balans      = 0;
                card.ValidDate   = DateTime.Now.AddYears(3);

                _dbContext.Cards.Add(card);
                await _dbContext.SaveChangesAsync();
            }
            return(NoContent());
        }
コード例 #3
0
        public async Task <ActionResult> Put(string salary)
        {
            List <SalaryModel> salaryList = JsonConvert.DeserializeObject <List <SalaryModel> >(salary);
            var Cards = _dbContext.Cards.ToList();

            foreach (var item in salaryList)
            {
                _dbContext.Cards.Where(m => m.User.IDCardNumber == item.IDCardNumber).FirstOrDefault().Balans += item.Balance;
                await _dbContext.SaveChangesAsync();
            }
            return(NoContent());
        }
コード例 #4
0
        public async Task <IActionResult> PutBank(int id, Bank bank)
        {
            if (id != bank.BankID)
            {
                return(BadRequest());
            }

            _context.Entry(bank).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (Exception)
            {
                if (!BankExists(id))
                {
                    return(NotFound());
                }
                throw;
            }

            return(NoContent());
        }