Example #1
0
        public async Task <IActionResult> Create(AccountRequestModelV9 model)
        {
            ActionResultV9 result = await this.service.Create(model);

            if (result.Success)
            {
                return(this.Ok(result.Object));
            }
            else
            {
                return(this.StatusCode(422));
            }
        }
Example #2
0
        public async Task <ActionResultV9> Create(AccountRequestModelV9 model)
        {
            ValidationResult result = this.modelValidator.Validate(model);

            if (result.IsValid)
            {
                if (!await this.fbiService.VerifyWithFBI(model.SSN))
                {
                    return(new ActionResultV9(false, new ValidationResultV9(false, "Unable to validate with FBI")));
                }

                model.SetDateCreated(this.dateService.Now());

                Account account = this.mapper.MapRequestToEntity(model);

                this.repository.Create(account);

                return(new ActionResultV9(true, this.mapper.MapEntityToResponse(account)));
            }
            else
            {
                return(new ActionResultV9(result));
            }
        }
Example #3
0
 public Account MapRequestToEntity(AccountRequestModelV9 model)
 {
     return(new Account(model.Id, model.Name, model.SSN, model.DateCreated, model.Token));
 }