Esempio n. 1
0
        public IActionResult AccountAdd(AccountAdd model)
        {
            var createResult   = false;
            var httpWebRequest = (HttpWebRequest)WebRequest.Create("https://localhost:44354/api/account/create");

            httpWebRequest.ContentType = "application/json";
            httpWebRequest.Method      = "POST";

            using (var streamWriter = new StreamWriter(httpWebRequest.GetRequestStream()))
            {
                var json = JsonConvert.SerializeObject(model);

                streamWriter.Write(json);
            }

            var httpResponse = (HttpWebResponse)httpWebRequest.GetResponse();

            using (var streamReader = new StreamReader(httpResponse.GetResponseStream()))
            {
                var result = streamReader.ReadToEnd();
                createResult = bool.Parse(result);
            }
            if (createResult)
            {
                TempData["Success"] = "Account has been created successfully";
            }
            ModelState.Clear();
            return(View(new AccountAdd()
            {
            }));
        }
        /// <summary>
        /// Add a new account, just like you would on the Manage Accounts page of the reseller panel.
        /// </summary>
        /// <param name="model">AccountModel</param>
        /// <returns>AccountResponseModel</returns>
        public AccountAddResponse AccountAdd(AccountAdd model)
        {
            try
            {
                var postData = new Dictionary <string, string>()
                {
                    { "account", model.AccountName },
                    { "cname", model.Cname },
                    { "name", model.Name },
                    { "email", model.Email },
                    { "notification", model.Notification },
                    { "plan", model.PlanId.ToString() },
                    { "language", model.Language },
                    { "timezone", model.Timezone }
                };

                var jsonResponse = SendRequest("account_add", null, postData);

                var response = JsonConvert.DeserializeObject <AccountAddResponse>(jsonResponse);

                return(response);
            }
            catch (Exception ex)
            {
                throw new ExceptionService(ex.Message);
            }
        }
Esempio n. 3
0
        public async Task <IActionResult> RegistryEndPoint([FromBody] AccountAdd newAccount)
        {
            if (!ModelState.IsValid)
            {
                return(new BadRequestObjectResult(ModelState));
            }

            var newUserIdentity = _manager.IdentityGetMapped(newAccount);
            //newUserIdentity.DOB = DateTime.Parse(newAccount.DOB);

            var result = await _userManager.CreateAsync(newUserIdentity, newAccount.Password);

            if (!result.Succeeded)
            {
                return(new BadRequestObjectResult("The User Cannot Be Registered"));
            }

            await _dataDbContext.Accounts.AddAsync(new Account { IdentityCustomModelId = newUserIdentity.Id,
                                                                 SearchBasicLimit      = 50,
                                                                 SearchBasicNum        = 0,
                                                                 SearchRegularLimit    = 250,
                                                                 SearchRegularNum      = 0,
                                                                 LastRequest           = DateTime.Now, });

            await _dataDbContext.SaveChangesAsync();

            return(new OkObjectResult("Account Has Been Created"));
        }
Esempio n. 4
0
        public async Task <HttpResponseMessage> AddSavingDetails(Guid owner, Guid account, SavingAccountIn saving)
        {
            var input = new AccountAdd {
                CurrentAccount = account, Saving = saving
            };

            return(await this.ProcessActionAsync(owner, input, this.accountService.AddSavingAccount));
        }
Esempio n. 5
0
        public async Task <HttpResponseMessage> AddLoanDetails(Guid owner, Guid account, LoanAccountIn loan)
        {
            var input = new AccountAdd {
                CurrentAccount = account, Loan = loan
            };

            return(await this.ProcessActionAsync(owner, input, this.accountService.AddLoanAccount));
        }
Esempio n. 6
0
        public ResSubmit ThemMoiTaiKhoan(AccountAdd accountNew, AccountCookie accountCookie)
        {
            tongcuclamnghiepEntities tongcuclamnghiep = new tongcuclamnghiepEntities();
            ResSubmit respons = new ResSubmit(true, "Thêm mới thành công");
            var       regex   = new Regex(@"^[a-zA-Z0-9]+$");

            if (!regex.IsMatch(accountNew.UserName))
            {
                respons = new ResSubmit(false, "Username không đúng định dạng");
            }
            regex = new Regex(@"^((([a-zA-Z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+(\.([a-zA-Z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+)*)|((\x22)((((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(([\x01-\x08\x0b\x0c\x0e-\x1f\x7f]|\x21|[\x23-\x5b]|[\x5d-\x7e]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(\\([\x01-\x09\x0b\x0c\x0d-\x7f]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))))*(((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(\x22)))@((([a-zA-Z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-zA-Z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-zA-Z]|\d|-|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-zA-Z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-zA-Z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-zA-Z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-zA-Z]|\d|-|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-zA-Z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))$");
            if (respons.success == true && !regex.IsMatch(accountNew.Email))
            {
                respons = new ResSubmit(false, "Email không đúng định dạng");
            }
            if (respons.success == true)
            {
                string password = Membership.GeneratePassword(12, 1);

                if (tongcuclamnghiep.m_account.Any(a => a.email == accountNew.Email))
                {
                    respons = new ResSubmit(false, "Email đã tồn tại trong hệ thống");
                }
                if (tongcuclamnghiep.m_account.Any(a => a.username == accountNew.UserName))
                {
                    respons = new ResSubmit(false, "Username đã tồn tại trong hệ thống");
                }
                if (!tongcuclamnghiep.m_role.Any(a => a.id == accountNew.Role && a.status == true))
                {
                    respons = new ResSubmit(false, "Quyền không tồn tại trong hệ thống");
                }
                if (respons.success == true)
                {
                    m_account _Account = new m_account();
                    _Account.createdate = DateTime.Now;
                    _Account.email      = accountNew.Email;
                    _Account.fullname   = accountNew.FullName;
                    _Account.gender     = accountNew.Gender == 1;
                    _Account.role_id    = accountNew.Role;
                    _Account.password   = password;
                    _Account.status     = true;
                    _Account.username   = accountNew.UserName;
                    tongcuclamnghiep.m_account.Add(_Account);

                    if (tongcuclamnghiep.SaveChanges() != 1)
                    {
                        respons = new ResSubmit(false, "Thêm mới thất bại");
                    }
                }
            }
            return(respons);
        }
 public bool AccountAdd(AccountAdd request)
 {
     try
     {
         DynamicParameters parameters = new DynamicParameters();
         parameters.Add("@UserName", request.UserName);
         parameters.Add("@Password", request.Password);
         parameters.Add("@Role", request.Role);
         SqlMapper.Execute(con, "Account_Add", param: parameters, commandType: CommandType.StoredProcedure);
         return(true);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Esempio n. 8
0
        /// <summary>
        /// The add loan account.
        /// </summary>
        /// <param name="owner">
        /// The owner.
        /// </param>
        /// <param name="input">
        /// The input.
        /// </param>
        /// <returns>
        /// The <see cref="Task"/>.
        /// </returns>
        public async Task <Guid> AddLoanAccount(Guid owner, AccountAdd input)
        {
            var id = Guid.NewGuid();

            if (!this.cacheProvider.Banks.Select(x => x.Code).Contains(input.Loan.Bank))
            {
                throw new Exception("The Bank " + input.Loan.Bank + " doesnt look valid.");
            }

            if (!this.cacheProvider.Currencies.Select(x => x.Code).Contains(input.Loan.Currency))
            {
                throw new Exception("The currency " + input.Loan.Currency + " doesnt look valid.");
            }

            var done = await this.accountRepository.Add(owner, input.CurrentAccount, id, input.Loan);

            if (done == 1)
            {
                return(id);
            }

            return(Guid.Empty);
        }
 public bool AccountAdd(AccountAdd request)
 {
     return(_accountRepository.AccountAdd(request));
 }
 public bool Account_Add([FromBody] AccountAdd request)
 {
     return(_accountService.AccountAdd(request));
 }