예제 #1
0
        public IActionResult CreateAccount(AccountsModel account)
        {
            Random rnd = new Random();
            ulong  rndNum;

            do
            {
                rndNum = 4000000000 + (ulong)rnd.Next(0, 999999999);
            }while (_service.IsAccountExist(rndNum.ToString()));

            account.AccountNumber = rndNum.ToString();
            account.DateCreated   = DateTime.Now.ToString("dd.MM.yyyy, HH:mm:ss");
            account.Id            = Guid.NewGuid();

            if (_service.CreateAccount(account))
            {
                return(Ok(account));
            }

            return(BadRequest());
        }