protected void ButtonCustomers_Click(object sender, EventArgs e) { SqlConnection conn; SqlCommand comm; SqlDataReader reader; string connectionString = ConfigurationManager.ConnectionStrings["DVDconnstring"].ConnectionString; conn = new SqlConnection(connectionString); comm = new SqlCommand("SELECT CustomerID, FirstName, LastName FROM Customers", conn); try { conn.Open(); reader = comm.ExecuteReader(); GetCustomer.DataSource = reader; GetCustomer.DataBind(); reader.Close(); } catch { dbErrorLabel.Text = "Error getting Customer Info<br />"; } finally { conn.Close(); } }
public void Can_post_raw_response_as_raw_JSON() { var request = new GetCustomer { CustomerId = 5 }; var response = client.Post(request); Assert.That(response.Customer.Id, Is.EqualTo(5)); var requestPath = request.ToPostUrl(); string json = request.ToJson(); response = client.Post <GetCustomerResponse>(requestPath, json); Assert.That(response.Customer.Id, Is.EqualTo(5)); byte[] bytes = json.ToUtf8Bytes(); response = client.Put <GetCustomerResponse>(requestPath, bytes); Assert.That(response.Customer.Id, Is.EqualTo(5)); Stream ms = bytes.InMemoryStream(); response = client.Post <GetCustomerResponse>(requestPath, ms); Assert.That(response.Customer.Id, Is.EqualTo(5)); }
public async Task Can_post_raw_response_as_raw_JSON_HttpClient() { var httpClient = new JsonHttpClient(BaseUrl); var request = new GetCustomer { CustomerId = 5 }; var response = httpClient.Post(request); Assert.That(response.Customer.Id, Is.EqualTo(5)); var requestPath = request.ToPostUrl(); string json = request.ToJson(); response = await httpClient.PostAsync <GetCustomerResponse>(requestPath, json); Assert.That(response.Customer.Id, Is.EqualTo(5)); byte[] bytes = json.ToUtf8Bytes(); response = await httpClient.PutAsync <GetCustomerResponse>(requestPath, bytes); Assert.That(response.Customer.Id, Is.EqualTo(5)); Stream ms = bytes.InMemoryStream(); response = await httpClient.PostAsync <GetCustomerResponse>(requestPath, ms); Assert.That(response.Customer.Id, Is.EqualTo(5)); }
public void CanGetCreateCustomer() { CreateCustomer newCustomer = new CreateCustomer { email = "*****@*****.**", name = "President", locale = "en_US", metadata = "something" }; GetCustomer createdCustomer = mollieClient.CreateCustomer(newCustomer); Assert.AreEqual(newCustomer.name, createdCustomer.name); Assert.AreEqual(newCustomer.email, createdCustomer.email); Assert.AreEqual(newCustomer.metadata, createdCustomer.metadata); Assert.AreEqual(newCustomer.locale, createdCustomer.locale); Assert.AreEqual("test", createdCustomer.mode); Assert.AreEqual("customer", createdCustomer.resource); Assert.IsTrue(createdCustomer.id.Length > 1); GetCustomer getCustomer = mollieClient.GetCustomer(createdCustomer.id); Assert.AreEqual(getCustomer.name, createdCustomer.name); Assert.AreEqual(getCustomer.name, createdCustomer.name); Assert.AreEqual(getCustomer.email, createdCustomer.email); Assert.AreEqual(getCustomer.metadata, createdCustomer.metadata); Assert.AreEqual(getCustomer.locale, createdCustomer.locale); Assert.AreEqual("test", getCustomer.mode); Assert.AreEqual("customer", getCustomer.resource); Customers customers = mollieClient.ListCustomers(); Assert.IsTrue(customers.data.Count > 0); }
private void btnNext_Click(object sender, EventArgs e) { if (counter == 0) { counter = 1; } else { bool cntrlCard = Check.ControlCustomer(lblCardNo.Text); bool cntrlPass = Check.ControlPassword(lblPassword.Text, lblCardNo.Text); if (cntrlCard && cntrlPass) { List <Customers> csList = GetCustomer.GetAllCustomers(); foreach (Customers item in csList) { if (item.CardNo == lblCardNo.Text) { Form2 frm = new Form2(item); frm.ShowDialog(); } } } else { MessageBox.Show("Password or CardNo is wrong"); } } }
public GetCustomer GetCustomer(string id) { string jsonData = LoadWebRequest("GET", "customers/" + id, ""); GetCustomer getCustomer = JsonConvert.DeserializeObject <GetCustomer>(jsonData, new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore }); return(getCustomer); }
public void Can_GetCustomers() { var request = new GetCustomer { CustomerId = 5 }; Send <GetCustomerResponse>(request, response => Assert.That(response.Customer.Id, Is.EqualTo(request.CustomerId))); }
public async Task GetCustomerTest() { var expected = "1"; var data = new GetCustomer(expected); var result = await Sut.Handle(data, CancellationToken.None); Assert.Equal(expected, result.Id); }
public object Get(GetCustomer request) { var customer = documentSession.Load <Customer>(request.Id); if (customer == null) { HttpError.NotFound("Customer not found!"); } return(customer); }
public GetCustomerResponse Get(GetCustomer request) { var customer = Db.SingleById<Customer>(request.Id); if (customer == null) throw HttpError.NotFound("Customer not found"); return new GetCustomerResponse { Result = Db.SingleById<Customer>(request.Id) }; }
public GetCustomer CreateCustomer(CreateCustomer customer) { string jsonData = LoadWebRequest("POST", "customers", JsonConvert.SerializeObject(customer, new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore })); GetCustomer getCustomer = JsonConvert.DeserializeObject <GetCustomer>(jsonData, new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore }); return(getCustomer); }
public void AutoWiredFunq_Perf() { RegisterServices(serviceController, GetAutoWiredFunqTypeFactory()); StoreAndGetCustomers(serviceController); var request = new GetCustomer { CustomerId = 2 }; Console.WriteLine("AutoWiredFunq_Perf(): {0}", Measure(() => serviceController.Execute(request), Times)); }
public object Get(GetCustomer request) { return this.Request.ToOptimizedResultUsingCache(this.Cache, CacheKey.Fmt(request.Id), () => { Thread.Sleep(500); //Long request return new GetCustomerResponse { Result = this.Db.LoadSingleById<Customer>(request.Id) }; }); }
public object Get(GetCustomer request) { return(this.Request.ToOptimizedResultUsingCache(this.Cache, CacheKey.Fmt(request.Id), () => { Thread.Sleep(500); //Long request return new GetCustomerResponse { Result = this.Db.LoadSingleById <Customer>(request.Id) }; })); }
public void CanNotGetNonExistingCustomer() { try { GetCustomer getCustomer = mollieClient.GetCustomer("non-existing-customer"); } catch (Exception ex) { Assert.IsTrue(ex.Message.Contains("The customer id is invalid")); return; } Assert.Fail("Did not throw exception"); }
public static bool ControlCustomer(string cardNo) { bool sonuc = false; List <Customers> csList = GetCustomer.GetAllCustomers(); foreach (Customers item in csList) { if (item.CardNo == cardNo) { sonuc = true; } } return(sonuc); }
public GetCustomerResponse Get(GetCustomer request) { var customer = Db.SingleById <Customer>(request.Id); if (customer == null) { throw HttpError.NotFound("Customer not found"); } return(new GetCustomerResponse { Result = Db.SingleById <Customer>(request.Id) }); }
public async Task CustomersController_GetAll() { //Arrange GetCustomer gc = new GetCustomer(); gc.Id = Guid.NewGuid(); //Act var result = await controller.Get(gc); var contentResult = result as ActionResult <CustomerDto>; //Assert contentResult.Should().NotBeNull(); }
public async Task GetCustomer_Handle_isDto() { //Arange GetCustomerHandler _handler = new GetCustomerHandler(_customersRepo.Object); GetCustomer query = new GetCustomer(); query.Id = Guid.NewGuid(); //Act CustomerDto customer = await _handler.HandleAsync(query); //Assert Assert.IsType <CustomerDto>(customer); }
public bool GetCustomer(string logId, DateTime startDate, DateTime endDate) { var customer = new GetCustomer(); var resp = customer.GetListofAMCustomer(startDate, endDate, logId); common.InsertSuiteAmIntegrationLogDetail(new CreateTraceLogRequest() { Description = "Customer sync ended", Name = "GetCustomer", Entity_c = "Customer" }, logId); SuiteWrapper.WriteTraceLog("GetCustomer", "---------------- CUSTOMER SYNC END ------------------------- "); if (resp.StatusCode == 5) { return(true); } return(false); }
public async Task <IActionResult> Single(Guid id) { if (id == Guid.Empty) { return(this.BadRequest("A valid id is required")); } var query = new GetCustomer(id: id); var customerViewModel = await this.Dispatcher.Query <GetCustomer, CustomerLite>(query); if (customerViewModel == null) { return(this.NotFound($"Resource with identifier '{id}' not found")); } return(this.Ok(customerViewModel)); }
// GET: CustomerController/Edit/5 public ActionResult Edit(int id) { var request = new GetCustomer() { Id = id }; var response = mediator.Send(request).Result; var customer = new Customer() { Id = response.Id, Name = response?.Name, Surname = response?.Surname, EmailAddress = response?.EmailAddress, TelephoneNumber = response?.TelephoneNumber }; return(View(customer)); }
public CustomerContract Process(GetCustomerRequest input) { var parameter = new GetCustomer { OrganizationId = input.OrganizationId, CustomerId = input.Id }; _query.BuildQuery(parameter); using (DapperUnitOfWork.Begin()) { var customer = _runner.Run(_query); var result = CustomerMapper.Map(customer); return(result); } }
public static async Task MainAsync(string[] args) { var dispatcher = ServiceProvider.GetService <IDispatcher>(); // Command - Exception var createFaultedCustomerCommand = new CreateCustomer(); var faultedResult = await dispatcher.Command(createFaultedCustomerCommand); // Command Create var createCustomerCommand = new CreateCustomer(); createCustomerCommand.FirstName = "Louis"; createCustomerCommand.LastName = "Lewis"; createCustomerCommand.UserName = "******"; var createResult = await dispatcher.Command(createCustomerCommand); var createdCustomerId = Guid.Parse(((CommandResult)createResult).RecordId); // Query Paged var queryPage = new QueryPage(); var queryPagedResult = await dispatcher.Query <QueryPage, GenericResultsList <CustomerLite> >(queryPage); // Query Single Lite var getCustomerQuery = new GetCustomer(id: createdCustomerId); var customerLite = await dispatcher.Query <GetCustomer, CustomerLite>(getCustomerQuery); // Query Single Detail var customerDetail = await dispatcher.Query <GetCustomer, CustomerDetail>(getCustomerQuery); // Command Delete var deleteCommand = new DeleteCustomer(id: createdCustomerId); var deleteResult = await dispatcher.Command(deleteCommand); // Message var exception = new NotImplementedException("Lets throw an exception"); var exceptionMessage = new ExceptionMessage { Exception = exception }; await dispatcher.Message(exceptionMessage); }
public CustomerResponse getCustomerById(string id) { var storeScope = this.GetActiveStoreScopeConfiguration(_storeService, _workContext); CustomerResponse CustomerResponse = null; var customer = new CustomerMessage(); customer.id = id; var ContaAzulMiscSettings = _settingService.LoadSetting <ContaAzulMiscSettings>(storeScope); try { using (var getcustomer = new GetCustomer(ContaAzulMiscSettings.UseSandbox)) CustomerResponse = getcustomer.CreateAsyncById(customer, ContaAzulMiscSettings.access_token).ConfigureAwait(false).GetAwaiter().GetResult(); } catch (Exception ex) { try { var retorno = JsonConvert.DeserializeObject <MiscExecutitionResponse>(ex.Message, ConverterPaymentExecution.Settings); if (retorno.StatusCode == "401") { RefreshToken(); _logger.Error("Token expirado " + ContaAzulMiscSettings.access_token, ex); } else { _logger.Error(ex.Message, ex); } } catch (Exception erro) { _logger.Error(erro.Message, erro); throw; } } return(CustomerResponse); }
public object Any(GetCustomer request) { if (config.UseCache) { var inCache = this.CacheClient.Get <GetCustomerResponse>(CacheKey); if (inCache != null) { return(inCache); } } var response = new GetCustomerResponse { Customer = db.SingleById <Customer>(request.CustomerId) }; if (config.UseCache) { this.CacheClient.Set(CacheKey, response); } return(response); }
public object Get(GetCustomer request) { String document = request.document; try { if (document == null || document.Trim().Length == 0) { return(Db.Select <Customer>("select * from dbo.Customer")); } else { var varDocument = document; return(Db.SqlList <Customer>("select * from dbo.Customer where document = (@varDocument)", new { varDocument })); } }catch (System.Data.SqlClient.SqlException ex) { return(new ErrorMessageResponse { error = ex.Message }); } }
public virtual async Task Consume(ReceiveContext <OrderCreated> messageContext) { var message = messageContext.Message; var customerRequest = new GetCustomer(message.CustomerId); var customer = await this.requestBus.Request <GetCustomer, Customer>(customerRequest); var orderStatus = await this.GetOrderStatus(message.OrderStatus); var orderReview = new OrderReview( message.OrderId, customer.Name, message.OrderTotal, orderStatus.Description); this.uow.Add(orderReview); foreach (var eventItem in message.Items) { var productRequest = new GetProduct(eventItem.ProductId); var product = await this.requestBus.Request <GetProduct, Product>(productRequest); var item = new OrderItem( message.OrderId, eventItem.LineNumber, product.Name, eventItem.Quantity, eventItem.Price); this.uow.Add(item); } await this.uow.Save(); if (message.OrderStatus == OrderStatusEnum.OrderSuspended) { var response = new OrderStatusResponse(orderStatus.LongDescription); await messageContext.Respond(response); } }
/// <summary> /// This code uses the GetCustomer class to retrieve the first and last name /// of the user associated with the entered login information. /// It then displays the name in a welcome message on the page. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void Page_Load(object sender, EventArgs e) { if (Session["person"] != null) { int personKey = (int)Session["person"]; GetCustomer gc = new GetCustomer(personKey); string customerName = null; DataSet ds = gc.GetName(); foreach (DataRow row in ds.Tables["Customer"].Rows) { customerName = row["FirstName"].ToString() + " " + row["LastName"].ToString(); } lblCustomerName.Text = "Welcome " + customerName + "!"; } else { Response.Redirect("Default.aspx"); } }
public ActionResult Details(int id) { var getVehicle = new GetVehicle() { Id = id }; var vehicleResult = mediator.Send(getVehicle).Result; var vehicle = new Vehicle() { Id = vehicleResult.Id, Brand = vehicleResult?.Brand, LicenseNumber = vehicleResult?.LicenseNumber, Type = vehicleResult?.Type, OwnerId = vehicleResult.OwnerId }; var getCustomer = new GetCustomer() { Id = vehicle.OwnerId }; var ownerResult = mediator.Send(getCustomer).Result; var owner = new Customer() { Id = ownerResult.Id, Name = ownerResult.Name, Surname = ownerResult.Surname, }; var view = new VehicleDetailsViewModel() { Vehicle = vehicle, Customer = owner }; return(View(view)); }
protected void Page_Load(object sender, EventArgs e) { //The code on this page calls on the "person" session to retrieve the Person Key of the logged-in user, then uses that key to retrieve the necessary customer data from the Automart database to populate the information displayed on Default5.aspx try { if (Session["person"] != null) { int personKey = (int)Session["person"]; //This section of code uses ADO to retrieve the user's name and email address using the GetCustomer class GetCustomer gc = new GetCustomer(personKey); string customerName = null; DataSet ds = gc.GetName(); foreach (DataRow row in ds.Tables["Customer"].Rows) { customerName = row["FirstName"].ToString() + " " + row["LastName"].ToString(); } WelcomeLbl.Text = "Welcome " + customerName + "!"; string customerEmail = null; DataSet ds2 = gc.GetEmail(); foreach (DataRow row in ds2.Tables["RegisteredCustomer"].Rows) { customerEmail = row["Email"].ToString(); } EmailLbl.Text = "Your registered email address is: " + customerEmail + "."; //From here, Ado.Net Data Entities is used to select vehicle and service information for the logged in user and bind // that information to the corresponding datalist on Default5.aspx AutomartModel.AutomartEntities ame = new AutomartModel.AutomartEntities(); var veh = from v in ame.vehicles where v.PersonKey == personKey orderby v.VehicleId select new { v.VehicleId, v.LicenseNumber, v.VehicleMake, v.VehicleYear}; VehicleDL.DataSource = veh.ToList(); VehicleDL.DataBind(); var num = (from n in ame.VehicleServices where n.vehicle.PersonKey == personKey select n).Count(); if (num == 0) { NoHistoryLbl.Text = "You have no auto service history with AutoMart."; NoHistoryLbl2.Text = "You have no auto service history with AutoMart."; } var ser = from s in ame.VehicleServices where s.vehicle.PersonKey == personKey orderby s.VehicleID select new { s.VehicleServiceID, s.VehicleID, s.LocationID, s.ServiceDate, s.ServiceTime }; ServiceDL.DataSource = ser.ToList(); ServiceDL.DataBind(); var det = from d in ame.VehicleServiceDetails where d.VehicleService.vehicle.PersonKey == personKey orderby d.VehicleServiceID select new { d.VehicleServiceID, d.AutoServiceID, d.serviceNotes}; DetailsDL.DataSource = det.ToList(); DetailsDL.DataBind(); var loc = from l in ame.Locations orderby l.LocationID select new { l.LocationID, l.LocationName}; LocationIdDL.DataSource = loc.ToList(); LocationIdDL.DataBind(); var auto = from a in ame.AutoServices orderby a.AutoServiceID select new {a.AutoServiceID, a.ServiceName}; AutoServiceDL.DataSource = auto.ToList(); AutoServiceDL.DataBind(); } else { Response.Redirect("Default2.aspx", false); } } catch (Exception ex) { Session["error"] = ex.Message; Response.Redirect("Default6.aspx"); } }
CustomerModel ExecuteQuery(GetCustomer query) { var customer = _data.OfType <CustomerModel>().SingleOrDefault(cust => cust.Id == query.Id); return(customer); }
public object Post(GetCustomer request) { return Db.SingleById<Customer>(request.ID); }
/// <inheritdoc cref="GetCustomerAsync(Commands.GetCustomer,CancellationToken)"/> public GetCustomerResponse GetCustomer(GetCustomer getCustomer) => Post <GetCustomer, GetCustomerResponse>(getCustomer);
/// <summary> /// Метод регистрирует покупателя и его данные в системе продавца. /// </summary> /// <returns></returns> public Task <GetCustomerResponse> GetCustomerAsync(GetCustomer getCustomer, CancellationToken cancellationToken) => PostAsync <GetCustomer, GetCustomerResponse>(getCustomer, cancellationToken);
public object Get(GetCustomer request) { var customer = documentSession.Load<Customer>(request.Id); if (customer == null) HttpError.NotFound("Customer not found!"); return customer; }