コード例 #1
0
        public async Task <IWrappedResponse> GetByCustomerId(int customerId)
        {
            var user = _userRepo.FindAll()
                       .ProjectTo <User>(Mapper.ConfigurationProvider)
                       .SingleOrDefault();

            user.Role = AuthData.GetUserRole();

            var customerResult = (IWrappedResponse <Customer>) await _customersService.GetById(customerId);

            if (customerResult.ResultType == ResultType.NotFound)
            {
                return(NotFound <User>(customerId));
            }

            var customers = new[] { customerResult.Data };
            var postingAccountsServiceResponse = (IWrappedResponse <IEnumerable <PostingAccount> >) await _postingAccountsService.GetByCustomerId(customerId);

            var postingAccounts = postingAccountsServiceResponse.Data;
            var permissions     = Array.Empty <UserPermission>();

            user.Customers       = customers;
            user.PostingAccounts = postingAccounts;
            user.Permissions     = permissions;

            return(Ok(user));
        }
コード例 #2
0
        public IActionResult GetById(int id)
        {
            var result = _customersService.GetById(id);

            if (result.Success)
            {
                return(Ok(result));
            }
            return(BadRequest(result));
        }
コード例 #3
0
        public async Task <IActionResult> Get(int customerId, CancellationToken cancellationToken = default)
        {
            var customer = await _customersService.GetById(customerId, cancellationToken);

            if (customer == null)
            {
                return(NotFound());
            }
            return(Ok(customer));
        }
コード例 #4
0
 public Task <ActionResult <Customer> > GetById(int id)
 {
     return(_customersService.GetById(id).Convert <Customer>(this));
 }
コード例 #5
0
 public IHttpActionResult getById(int id)
 {
     return(Ok(customerService.GetById(id)));
 }