public FindCustomerResponse FindCustomer(FindCustomerRequest request)
        {
            AdministrationServiceDAO adminDAO = new AdministrationServiceDAO();
            customer c = adminDAO.FindCustomer(Convert.ToInt32(request.id), request.first_name, request.last_name, request.tax_number);

            return(new FindCustomerResponse(c));
        }
示例#2
0
        public async Task UpdateCustomer_ValidRequest_ReturnsResponse()
        {
            var customerRecord = _customerRecords[0];

            var updateRequest = new UpdateCustomerRequest
            {
                Id        = customerRecord.Id,
                FirstName = "New first name",
                LastName  = "New last name",
            };

            var updateResponse = await Fixture.Customers.UpdateCustomerAsync(updateRequest);

            Assert.Equal(updateRequest.Id, updateResponse.Id);
            Assert.Equal(updateRequest.FirstName, updateResponse.FirstName);
            Assert.Equal(updateRequest.LastName, updateResponse.LastName);

            var findRequest = new FindCustomerRequest {
                Id = updateRequest.Id
            };
            var findResponse = await Fixture.Customers.FindCustomerAsync(findRequest);

            Assert.Equal(updateResponse.Id, findResponse.Id);
            Assert.Equal(updateResponse.FirstName, findResponse.FirstName);
            Assert.Equal(updateResponse.LastName, findResponse.LastName);
        }
示例#3
0
        public async Task CreateCustomer_Valid_Created()
        {
            var createRequest = new CreateCustomerRequest
            {
                FirstName = "First name 1",
                LastName  = "Last name 1",
            };

            var createResponse = await Fixture.Api.Customers.CreateCustomerAsync(createRequest);

            Assert.Equal(HttpStatusCode.Created, createResponse.StatusCode);

            var createResponseContent = createResponse.Data;

            AssertUtilities.NotEmpty(createResponseContent.Id);

            Assert.Equal(createRequest.FirstName, createResponseContent.FirstName);
            Assert.Equal(createRequest.LastName, createResponseContent.LastName);

            var findRequest = new FindCustomerRequest {
                Id = createResponseContent.Id
            };

            var findResponse = await Fixture.Api.Customers.FindCustomerAsync(findRequest);

            Assert.Equal(HttpStatusCode.OK, findResponse.StatusCode);

            var findResponseContent = findResponse.Data;

            Assert.Equal(createResponseContent.Id, findResponseContent.Id);
            Assert.Equal(createRequest.FirstName, findResponseContent.FirstName);
            Assert.Equal(createRequest.LastName, findResponseContent.LastName);
        }
示例#4
0
        public async Task <ActionResult <FindCustomerResponse> > FindCustomerAsync(int id)
        {
            var request = new FindCustomerRequest {
                Id = id
            };
            var response = await Service.FindCustomerAsync(request);

            return(Ok(response));
        }
示例#5
0
        public async Task FindCustomer_NotExistRequest_ThrowsNotFoundRequestException()
        {
            var id = Guid.NewGuid();

            var findRequest = new FindCustomerRequest {
                Id = id
            };

            await Assert.ThrowsAsync <NotFoundRequestException>(() => Fixture.Customers.FindCustomerAsync(findRequest));
        }
示例#6
0
        public async Task FindCustomer_NotExist_NotFound()
        {
            var id = Guid.NewGuid();

            var findRequest = new FindCustomerRequest {
                Id = id
            };

            var findResponse = await Fixture.Api.Customers.FindCustomerAsync(findRequest);

            Assert.Equal(HttpStatusCode.NotFound, findResponse.StatusCode);
        }
示例#7
0
        public async Task FindCustomer_ValidRequest_ReturnsCustomer()
        {
            var customerRecord = _customerRecords[0];
            var id             = customerRecord.Id;

            var findRequest = new FindCustomerRequest {
                Id = id
            };
            var findResponse = await Fixture.Customers.FindCustomerAsync(findRequest);

            Assert.Equal(customerRecord.Id, findResponse.Id);
            Assert.Equal(customerRecord.FirstName, findResponse.FirstName);
            Assert.Equal(customerRecord.LastName, findResponse.LastName);
        }
示例#8
0
        public async Task FindCustomer_Valid_OK()
        {
            var customerRecord = _customerRecords[0];
            var id             = customerRecord.Id;

            var findRequest = new FindCustomerRequest {
                Id = id
            };

            var findResponse = await Fixture.Api.Customers.FindCustomerAsync(findRequest);

            Assert.Equal(HttpStatusCode.OK, findResponse.StatusCode);

            var findResponseContent = findResponse.Data;

            Assert.Equal(customerRecord.Id, findResponseContent.Id);
            Assert.Equal(customerRecord.FirstName, findResponseContent.FirstName);
            Assert.Equal(customerRecord.LastName, findResponseContent.LastName);
        }
示例#9
0
        public DataTable FindCustomer(CustomerInformation cinfo, bool strict, bool? bytime)
        {
            global::CustomerInformation ci = new global::CustomerInformation();
            ci.CompanyName = cinfo.CompanyName;
            ci.EMail = cinfo.EMail;
            ci.FirstName = cinfo.FirstName;
            if ((bool)bytime)
            {
                ci.LastModified = (Convert.ToDateTime(cinfo.LastModified));
                ci.LastModifiedSpecified = true;
            } else { ci.LastModifiedSpecified = false; }
            ci.LastName = cinfo.LastName;
            ci.Notes = cinfo.Notes;
            ci.PhoneNumber = cinfo.PhoneNumber;
            ci.SQLID = cinfo.SQLID;
            ci.SQLIDSpecified = true;

            FindCustomerRequest fcreq = new FindCustomerRequest(ci,strict,bytime);

            Task<FindCustomerResponse> fcres = _sqlService.FindCustomerAsync(fcreq);

            return fcres.Result.FindCustomerResult;
        }
示例#10
0
        public async Task CreateCustomer_ValidRequest_ReturnsResponse()
        {
            var createRequest = new CreateCustomerRequest
            {
                FirstName = "First name 1",
                LastName  = "Last name 1",
            };

            var createResponse = await Fixture.Customers.CreateCustomerAsync(createRequest);

            AssertUtilities.NotEmpty(createResponse.Id);
            Assert.Equal(createRequest.FirstName, createResponse.FirstName);
            Assert.Equal(createRequest.LastName, createResponse.LastName);

            var findRequest = new FindCustomerRequest {
                Id = createResponse.Id
            };

            var findResponse = await Fixture.Customers.FindCustomerAsync(findRequest);

            Assert.Equal(findRequest.Id, findResponse.Id);
            Assert.Equal(createRequest.FirstName, findResponse.FirstName);
            Assert.Equal(createRequest.LastName, findResponse.LastName);
        }
示例#11
0
        public Task <IObjectClientResponse <FindCustomerResponse> > FindCustomerAsync(FindCustomerRequest request)
        {
            var id = request.Id;

            return(Client.GetByIdAsync <Guid, FindCustomerResponse>(id));
        }
示例#12
0
 public Task <FindCustomerResponse> FindCustomerAsync(FindCustomerRequest request)
 {
     return(ExecuteAsync(e => e.FindCustomerAsync(request)));
 }
示例#13
0
 public Task <FindCustomerResponse> FindCustomerAsync(FindCustomerRequest request)
 {
     return(HandleAsync <FindCustomerRequest, FindCustomerResponse>(request));
 }