Esempio n. 1
0
        public async Task <BankAccount> UpdateAccountAsync(string accountNumber, AccountRequestModel account)
        {
            var jsonAccount = JsonConvert.SerializeObject(account);
            var httpContent = new StringContent(jsonAccount, Encoding.UTF8, "application/json");

            var response = await _requestSender.PatchAsync($"/accounts/{accountNumber}", httpContent);

            if (!response.IsSuccessStatusCode)
            {
                //TODO: create specific exception
                throw new Exception();
            }

            var stringResult = await response.Content.ReadAsStringAsync() ?? string.Empty;

            if (string.IsNullOrEmpty(stringResult))
            {
                //TODO: create specific exception
                throw new Exception();
            }

            var result = JsonConvert.DeserializeObject <BankAccount>(stringResult);

            return(result);
        }
Esempio n. 2
0
 public async Task <BankAccount> UpdateAccountAsync(string accountNumber, AccountRequestModel account)
 {
     return(new BankAccount
     {
         Id = "64426fc5-b3ac-42fb-b75b-d5ccfcdc6872",
         AccountNumber = accountNumber,
         Created = DateTime.Now.AddDays(-3),
         Modified = DateTime.Now,
         Trust = account.Message.Trust.ToString()
     });
 }
Esempio n. 3
0
        public async Task <IActionResult> UnBindOTP(AccountRequestModel request)
        {
            return(NotFound());

            SMSResponse response = new SMSResponse();

            response = await acc.BindAccount(request, "UnBind");

            if (response.phoneNumber == "")
            {
                return(NotFound(response));
            }
            return(Ok(response));
        }
Esempio n. 4
0
        public async Task <ActionResult> Details(AccountRequestModel request)
        {
            var user = await UserManager.FindByIdAsync(request.ApplicationUserID);


            if (user != null)
            {
                ProfileDetailsModel profile = new ProfileDetailsModel
                {
                    UserID    = user.Id,
                    FirstName = user.FirstName,
                    LastName  = user.LastName,
                    Email     = user.Email
                };

                return(Json(new { Success = true, User = profile }));
            }

            return(Json(new { Success = false }));
        }
Esempio n. 5
0
        public async Task <IActionResult> Bind(AccountRequestModel request)
        {
            acc.REST_KeepLogRequest("", func.JsonSerialize(request));
            try
            {
                SMSResponse response = new SMSResponse();
                response = await acc.BindAccount(request);

                if (response.phoneNumber == "")
                {
                    return(NotFound(response));
                }
                return(Ok(response));
            }
            catch (Exception e)
            {
                acc.REST_KeepLogRequest(e.Message, func.JsonSerialize(request));
                return(BadRequest(e.Message));
            }
        }
Esempio n. 6
0
        public async Task <IActionResult> Register(AccountRequestModel request)
        {
            try
            {
                acc.REST_KeepLogRequest("", func.JsonSerialize(request));
                string result = await acc.Register(request);

                if (result == "NotFound")
                {
                    Dictionary <string, string> response = new Dictionary <string, string>();
                    response.Add("result", "OTP Mismatch");
                    return(NotFound(response));
                }
                else if (result == "OTP Expire")
                {
                    Dictionary <string, string> response = new Dictionary <string, string>();
                    response.Add("result", result);
                    return(NotFound(response));
                }
                data    = cus.REST_GetAccountInformation(request.IDCard, request.BirthDay, "");
                profile = api.GetUserProfile(request.UserId);
                if (profile.Result != null)
                {
                    action.SP_InsertUserFollow(
                        request.UserId,
                        profile.Result.displayName,
                        profile.Result.pictureUrl,
                        profile.Result.statusMessage,
                        profile.Result.language
                        );
                }
                return(Ok(data));
            }
            catch (Exception e)
            {
                acc.REST_KeepLogRequest(e.Message, func.JsonSerialize(request));
                return(BadRequest(e.Message));
            }
        }
Esempio n. 7
0
        public IActionResult GetAll([FromBody] AccountRequestModel model)
        {
            if (!_accountDomainService.CheckIfUserExistsFromHeader(HttpContext.Request))
            {
                return(Unauthorized());
            }
            else
            {
                var accounts = _accountRepository.GetAll()
                               .Skip((model.Page - 1) * model.Size)
                               .Take(model.Size)
                               .ToList();

                var outputModel = accounts.Select(p => new AccountOutputModel
                {
                    Id   = p.Id,
                    Name = p.Name
                }).ToList();

                return(Ok(outputModel));
            }
        }
Esempio n. 8
0
        public async Task <IHttpActionResult> GetAccountsByFilter([FromUri] AccountRequestModel model)
        {
            if (model == null)
            {
                model = new AccountRequestModel {
                    limit = 20, offset = 0
                };
            }

            if (!string.IsNullOrEmpty(model.Email))
            {
                var user = await _userManager.FindByEmailAsync(model.Email);

                if (user != null)
                {
                    return(Ok(user.CreaterDomainToView()));
                }
                return(NotFound());
            }
            else if (!string.IsNullOrEmpty(model.Username))
            {
                var user = await _userManager.FindByNameAsync(model.Username);

                if (user != null)
                {
                    return(Ok(user.CreaterDomainToView()));
                }
                return(NotFound());
            }

            // If there are no conditions, then display all users
            var users = GetCollectionResult <AccountCreatedResponseModel>(
                getCount: () => _userManager.Users.Count(),
                getItems: () => _userManager.Users.ToList().Select(x => x.CreaterDomainToView()),
                modelState: ModelState);

            return(Ok(users));
        }