Example #1
0
        public string CreateCustomer(Customer customer)
        {
            var creationDenied = "får ej lämnas tomt, kunde ej skapa kund. Tryck [Enter] för att fortsätta.";

            if (string.IsNullOrWhiteSpace(customer.CompanyName))
            {
                return($"**** Företagsnamn {creationDenied} ****");
            }
            else if (string.IsNullOrWhiteSpace(customer.OrgNumber))
            {
                return($"**** Organisationsnummer {creationDenied} ****");
            }
            else if (string.IsNullOrWhiteSpace(customer.Address))
            {
                return($"**** Adress {creationDenied} ****");
            }
            else if (string.IsNullOrWhiteSpace(customer.PostalCode))
            {
                return($"**** Postnummer {creationDenied} ****");
            }
            else if (string.IsNullOrWhiteSpace(customer.Region))
            {
                return($"**** Postort {creationDenied} ****");
            }

            customer.CustomerNumber = _customerManager.CreateNewCustomerNumber();
            _accountManager.CreateAccount(customer.CustomerNumber);
            var newCustomer = _customerManager.CreateCustomer(customer);

            return("**** " + newCustomer.CompanyName + " skapat med kundnummer " + newCustomer.CustomerNumber + " . Tryck [Enter] för att fortsätta. ****");
        }
Example #2
0
        public async Task <CommandResult <Guid> > CreateClient([FromBody] CreateAccountViewModel accountViewModel)
        {
            var createAccountCommandModel = _mapper.Map <AccountModel>(accountViewModel);

            createAccountCommandModel.AccountRole = AdministratorRoles.Client_Role;
            return(await _accountManager.CreateAccount(createAccountCommandModel));
        }
Example #3
0
        public string SignUp(SignOn signUp)
        {
            //SignUp the User
            bool signedUp = _signService.SignUp(signUp);

            //Find AccId
            Guid AccId = _signService.SignIn(signUp);

            bool insertedAcc;
            //Create the template PersonalInfo
            bool insertedPersonal = _personalInfoManager.CreatePersonalInfo(Transformations.From_Acc_To_Person(AccId), AccId);

            //Create The Acc
            if (signedUp)
            {
                insertedAcc = _accManager.CreateAccount(signUp, AccId);
            }
            else
            {
                insertedAcc = false;
            }

            string accountNo;

            if (signedUp && insertedAcc && insertedPersonal)
            {
                accountNo = _accManager.RetrieveAccount(AccId).AccNo.ToString();
                return(accountNo);
            }
            else
            {
                return(null);
            }
        }
Example #4
0
        private void btOK_Click(object sender, EventArgs e)
        {
            string accountName = tbAccountName.Text.Trim();

            if (accountName == "")
            {
                MessageBox.Show("账号名不能为空");
                return;
            }
            if (accountManager.Exist(path, accountName))
            {
                MessageBox.Show("账号" + accountName + "已经存在");
                return;
            }

            double money = double.Parse(tbMoney.Text);

            this.account = accountManager.CreateAccount(money);

            RefreshAccountSetting(account.AccountSetting);
            this.accountName = tbAccountName.Text.Trim();
            accountManager.Save(path, accountName, account);
            this.DialogResult = DialogResult.OK;
            this.Close();
        }
Example #5
0
        public async Task <APIResponse> CreateAccount(AccountDetail model)
        {
            try
            {
                //Confirn the existence of the account
                var checkAccountNumber = await _accountManager.Exists(model.AccountNumber, model.AccountName);

                if (checkAccountNumber)
                {
                    throw new AccountDetailsAlreadyExistException($"Account details already exist");
                }

                await _accountManager.CreateAccount(model);

                return(new APIResponse {
                    ResponseObject = model
                });
            }
            catch (AccountDetailsAlreadyExistException ex)
            {
                throw;
            }
            catch (Exception ex)
            {
                throw;
            }
        }
        public void Delete_Account_Test()
        {
            var accountToRemove = _accountManager.CreateAccount(99);

            _accountManager.DeleteAccount(accountToRemove.AccountNumber);

            Assert.DoesNotContain(accountToRemove, _context.Accounts);
        }
Example #7
0
        public async Task <IActionResult> CreateAccount([FromBody] RegistrationViewModel model)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            await _accountsService.CreateAccount(model);

            return(StatusCode(StatusCodes.Status201Created, true));
        }
Example #8
0
 public ActionResult Register(RegisterUserViewModel registerUser)
 {
     ValidateRegisterUserViewModel(registerUser);
     if (ModelState.IsValid)
     {
         _accountManager.CreateAccount(registerUser.UserName, registerUser.Password, registerUser.FirstName, registerUser.LastName);
         _accountManager.SignIn(registerUser.UserName, HttpContext);
         return(RedirectToAction("Index", "Home"));
     }
     return(View(registerUser));
 }
Example #9
0
        public void Test()
        {
            IAccountManager fac     = DataCenter.Default.AccountManager;
            IAccount        account = fac.CreateAccount(100000);

            account.AccountSetting.TradeType = AccountTradeType.IMMEDIATELY;
            Plugin_MarketTrader_Simu trader = new Plugin_MarketTrader_Simu(account);

            OrderInfo order = new OrderInfo();

            order.Instrumentid = "rb1805";
            order.OpenClose    = OpenCloseType.Open;
            order.Volume       = 20;
            order.Price        = 2880;
            trader.SendOrder(order);
        }
        public IHttpActionResult CreateUser(AddAccountDto dto)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (_accountManager.CreateAccount(dto))
            {
                return(Ok(_accountManager.EwhAccountAdded));
            }
            else
            {
                return(ServerError(_accountManager as EwhEntityBase));
            }
        }
Example #11
0
        public async Task <IActionResult> CreateNewAccount([FromBody] AccountCreationDTO accountForCreation)
        {
            try
            {
                var acc    = mapper.Map <Account>(accountForCreation);
                var result = await accountManager.CreateAccount(acc);

                if (result == true)
                {
                    var accountToReturn = mapper.Map <AccountToReturnDTO>(acc);
                    return(CreatedAtRoute("GetAccount", new { Id = accountToReturn.AccountId }, accountToReturn));
                }
                return(BadRequest("Given Account could not be added."));
            }
            catch (Exception)
            {
                throw;
            }
        }
        public async Task <IActionResult> CreateAccountAsync([FromBody] Account request)
        {
            try
            {
                Account account = await accountManager.CreateAccount(request);

                if (account == null)
                {
                    return(BadRequest("Could not create a new account."));
                }

                return(Ok(account));
            }
            catch (DuplicateNameException)
            {
                return(new ConflictResult());
            }
            catch (Exception)
            {
                return(BadRequest());
            }
        }