public ActionResult Delete(int Id) { CustomerClient cusclt = new CustomerClient(); cusclt.Delete(Id); return(RedirectToAction("Index")); }
/// <summary> /// Prints the specified account's hierarchy using recursion. /// <param name="customerClient"> /// the customer client whose info will be printed and /// its child accounts will be processed if it's a manager /// </param> /// <param name="customerIdsToChildAccounts"> a Dictionary mapping customer IDs to /// child accounts</param> /// <param name="depth"> the current integer depth we are printing from in the /// account hierarchy</param> /// </summary> private void PrintAccountHierarchy(CustomerClient customerClient, Dictionary <long, List <CustomerClient> > customerIdsToChildAccounts, int depth) { if (depth == 0) { Console.WriteLine("Customer ID (Descriptive Name, Currency Code, Time Zone)"); } long customerId = customerClient.Id.Value; Console.Write(new string('-', depth * 2)); Console.WriteLine("{0} ({1}, {2}, {3})", customerId, customerClient.DescriptiveName, customerClient.CurrencyCode, customerClient.TimeZone); // Recursively call this function for all child accounts of $customerClient. if (customerIdsToChildAccounts.ContainsKey(customerId)) { foreach (CustomerClient childAccount in customerIdsToChildAccounts[customerId]) { PrintAccountHierarchy(childAccount, customerIdsToChildAccounts, depth + 1); } } }
public async Task CanUpdateCustomer() { // If: We retrieve the customer list var response = await CustomerClient.GetCustomerListAsync(); if (response.Items.Count == 0) { Assert.Empty(response.Items); //No customers found. Unable to test deleting customers return; } // When: We update one of the customers in the list var customerIdToUpdate = response.Items.First().Id; var newCustomerName = DateTime.Now.ToShortTimeString(); var updateParameters = new CustomerRequest() { Name = newCustomerName }; var result = await CustomerClient.UpdateCustomerAsync(customerIdToUpdate, updateParameters); // Then: Make sure the new name is updated Assert.NotNull(result); Assert.Equal(newCustomerName, result.Name); }
/// <summary> /// Éste metodo valida si el cliente existe y retorna la entidad representando el cliente /// </summary> /// <param name="userName"> /// Nombre de usuario del cliente /// </param> /// <param name="password"> /// Clave del cliente /// </param> /// <returns>La entidad del Cliente</returns> public static CustomerEntity ValidateAndGetCustomer(string userName, string password) { if (String.IsNullOrEmpty(userName) || String.IsNullOrEmpty(password)) { throw new ArgumentException( global::PresentationLayer.GeneralResources.UserNameEmpty); } Collection <CustomerEntity> customers = new Collection <CustomerEntity>(); SessionManagerClient sessionManagerClient = new SessionManagerClient(SessionManagerClient.CreateDefaultBinding(), new EndpointAddress(UtnEmall.Client.SmartClientLayer.Connection.ServerUri + "SessionManager")); string session = sessionManagerClient.ValidateCustomer(userName, Utilities.CalculateHashString(password)); CustomerClient customerClient = new CustomerClient(CustomerClient.CreateDefaultBinding(), new EndpointAddress(UtnEmall.Client.SmartClientLayer.Connection.ServerUri + "Customer")); customers = customerClient.GetCustomerWhereEqual(CustomerEntity.DBUserName, userName, true, session); if (customers.Count == 0) { throw new UtnEmallBusinessLogicException( global::PresentationLayer.GeneralResources.LoginFailedUserIncorrect); } string passwordHash = Utilities.CalculateHashString(password); CustomerEntity customer = customers[0]; if (String.Compare(customer.Password, passwordHash, StringComparison.Ordinal) != 0) { throw new UtnEmallBusinessLogicException( global::PresentationLayer.GeneralResources.LoginFailedPasswordIncorrect); } return(customer); }
public ActionResult Create(Customer customer) { CustomerClient customerClient = new CustomerClient(); bool result = customerClient.Create(customer); return(RedirectToAction("Index")); }
public async Task CreateAsync_Success() { CustomerRequest customerRequest = BuildCustomerCreateRequest(); var customerClient = new CustomerClient(); Customer customer = await customerClient.CreateAsync(customerRequest); await Task.Delay(1000); try { CustomerCardCreateRequest cardRequest = await BuildCardCreateRequestAsync(); CustomerCard card = await customerClient.CreateCardAsync(customer.Id, cardRequest); var request = new CardTokenRequest { CustomerId = customer.Id, CardId = card.Id, SecurityCode = "123", }; CardToken cardToken = await client.CreateAsync(request); Assert.NotNull(cardToken); Assert.NotNull(cardToken.Id); } finally { customerClient.Delete(customer.Id); } }
public long Add(CustomerClient obj) { if (IsDuplicate(obj.CustomerCode, obj.Id, obj.CustomerId) == false) { return(_customerClientRepository.Add(obj)); } else { Expression <Func <CustomerClient, bool> > res; res = x => x.CustomerCode.ToLower() == obj.CustomerCode.ToLower() && x.CustomerId == obj.CustomerId && x.IsActive == false; var customerClient = _customerClientRepository.Get(res); if (customerClient != null) { obj.Id = customerClient.Id; obj.IsActive = true; _customerClientRepository.Detach(customerClient); _customerClientRepository.Update(obj); return(obj.Id); } else { return(0); } } }
/// <summary> /// Saves the customer to the database /// </summary> public void SaveToDB() { CustomerClient temp = new CustomerClient(); if (temp.CheckIfEmailIsTaken(Email)) { // Get and open the connection using (MySqlConnection con = ApplicationSettings.GetConnection()) { con.Open(); // Insert the customer's properties to the database MySqlCommand cmd = new MySqlCommand( "INSERT INTO `customer`(`first_name`, `last_name`, `email`, `phone`) " + "VALUES (@fname,@lname,@email,@phone)", con); cmd.Parameters.AddWithValue("@fname", this.FirstName); cmd.Parameters.AddWithValue("@lname", this.LastName); cmd.Parameters.AddWithValue("@email", this.Email); cmd.Parameters.AddWithValue("@phone", this.Phone); cmd.ExecuteNonQuery(); // Retrieve the id from the database and assign it to the object this.ID = Convert.ToInt32(cmd.LastInsertedId); // Close the connection con.Close(); } } }
public void Constructor_NullParameters_Success() { var client = new CustomerClient(); Assert.Equal(MercadoPagoConfig.HttpClient, client.HttpClient); Assert.Equal(MercadoPagoConfig.Serializer, client.Serializer); }
public IHttpActionResult Update(CustomerClient CustomerClient) { try { bool success = _customerClientService.Update(CustomerClient, out bool IsDuplicate); if (IsDuplicate == true) { Log.Info($"{typeof(CustomerClientController).FullName}||{UserEnvironment}||Update record not successful, Customer Client Code is duplicate."); return(Content(HttpStatusCode.Forbidden, "Customer rClient Code is Duplicate")); } Log.Info($"{typeof(CustomerClientController).FullName}||{UserEnvironment}||Update record successful."); return(Content(HttpStatusCode.OK, "CustomerClient updated successfully")); } catch (System.Data.Entity.Validation.DbEntityValidationException ex) { dynamic errlist = new { Message = "Validation error", ErrorList = (from err in ex.EntityValidationErrors from error in err.ValidationErrors select error.ErrorMessage).Cast <object>().ToList() }; Log.Error(typeof(CustomerClientController).FullName, ex); return(Content(HttpStatusCode.BadRequest, errlist)); } catch (Exception ex) { Log.Error(typeof(CustomerClientController).FullName, ex); return(Content(HttpStatusCode.BadRequest, ex.Message)); } }
public OrderController() { _productClient = new ProductClient(); _employeeClient = new EmployeeClient(); _orderClient = new OrderClient(); _customerClient = new CustomerClient(); }
// GET: Customer public ActionResult Index() { CustomerClient customerClient = new CustomerClient(); List <Customer> customers = customerClient.findAll().ToList(); return(View(customers)); }
public ActionResult Edit(ClsCustomer cust) { CustomerClient cusclt = new CustomerClient(); cusclt.Edit(cust.customer); return(RedirectToAction("Index")); }
// // GET: /Customer/ public ActionResult Index() { CustomerClient cuslst = new CustomerClient(); ViewBag.listCustomer = cuslst.FindAll(); return(View()); }
private void Initialize(ICloudManagerClientSettings settings, HttpClient httpClient) { Customers = new CustomerClient(settings, httpClient); Services = new ServiceClient(settings, httpClient); Updates = new UpdateClient(settings, httpClient); SampleData = new SampleDataClient(settings, httpClient); }
public ActionResult AddGameServerProduct(GameServerViewModel model) { TempData[SuccessAddProduct] = false; if (Session[ORDER_SESSION] != null) { var product = CustomerClient.GetProduct(model.ID); var amountProduct = new AmountProduct(); amountProduct.Amount = 1; if (product.ProductType == EconomicRestClient.Models.ProductType.GameServer) { amountProduct.Product = model; } ((OrderViewModel)Session[ORDER_SESSION]).AmountProduct = amountProduct; TempData[SuccessAddProduct] = true; } else { return(RedirectToUmbracoPage(umbracoFailRedictPage)); } return(CurrentUmbracoPage()); }
public void Get_Success() { CustomerRequest customerRequest = BuildCustomerCreateRequest(); var customerClient = new CustomerClient(); Customer customer = customerClient.Create(customerRequest); Thread.Sleep(1000); try { CustomerCardCreateRequest cardRequest = BuildCardCreateRequest(); CustomerCard card = customerClient.CreateCard(customer.Id, cardRequest); var request = new CardTokenRequest { CustomerId = customer.Id, CardId = card.Id, SecurityCode = "123", }; CardToken createdCartToken = client.Create(request); Thread.Sleep(1000); CardToken cardToken = client.Get(createdCartToken.Id); Assert.NotNull(cardToken); Assert.Equal(createdCartToken.Id, cardToken.Id); } finally { customerClient.Delete(customer.Id); } }
public ActionResult Edit(CustomerViewModel CVM) { CustomerClient CC = new CustomerClient(); CC.Edit(CVM.customer); return(RedirectToAction("Index")); }
public ActionResult Delete(int id) { CustomerClient CC = new CustomerClient(); CC.Delete(id); return(RedirectToAction("Index")); }
public ActionResult Create(CustomerViewModel cvm) { CustomerClient CC = new CustomerClient(); CC.Create(cvm.customer); return(RedirectToAction("Index")); }
public void DeleteCustomer([FromUri] int id) { oCustRepo = kernel.Get <CustomerClient>(); Customer oCustomer = new Customer(); oCustomer.Id = id; oCustRepo.Delete(oCustomer); }
public void Constructor_Serializer_Success() { var serializer = new DefaultSerializer(); var client = new CustomerClient(serializer); Assert.Equal(MercadoPagoConfig.HttpClient, client.HttpClient); Assert.Equal(serializer, client.Serializer); }
public ActionResult Edit(int?id) { CustomerClient CC = new CustomerClient(); CustomerViewModel CVM = new CustomerViewModel(); CVM.customer = CC.find(id); return(View("Edit", CVM)); }
// GET: Customer public ActionResult Index() { CustomerClient CC = new CustomerClient(); ViewBag.listCustomers = CC.findAll(); return(View()); }
public ActionResult Edit(int Id) { CustomerClient cusclt = new CustomerClient(); ClsCustomer cus = new ClsCustomer(); cus.customer = cusclt.Find(Id); return(View("Edit", cus)); }
public void OrderModel_Test() { CustomerClient client = new CustomerClient(); client.OrderModel(Generator.CreateCustomer(), Generator.CreateCarModel()); // Verify it is indeed in database - for now we do it manually }
public void Execute() { var res = CustomerClient.UpdateCustomerTotalBuy(); Output.Add("CustomerMessage", res.Message); Output.Add("CustomerKey", res.CustomerKey); _logger.LogInformation(res.Message); }
public void VerifyEmail_Test_fail() { CustomerClient client = new CustomerClient(); Assert.AreEqual(client.CheckIfEmailIsTaken("*****@*****.**"), false); // Verify it is indeed in database - for now we do it manually }
public void VerifyEmail_Test() { CustomerClient client = new CustomerClient(); Assert.AreEqual(client.CheckIfEmailIsTaken("*****@*****.**"), true); // Verify it is indeed in database - for now we do it manually }
/// <summary>Snippet for GetCustomerClient</summary> /// <remarks> /// This snippet has been automatically generated for illustrative purposes only. /// It may require modifications to work in your environment. /// </remarks> public void GetCustomerClientResourceNames() { // Create client CustomerClientServiceClient customerClientServiceClient = CustomerClientServiceClient.Create(); // Initialize request argument(s) CustomerClientName resourceName = CustomerClientName.FromCustomerClientCustomer("[CUSTOMER_ID]", "[CLIENT_CUSTOMER_ID]"); // Make the request CustomerClient response = customerClientServiceClient.GetCustomerClient(resourceName); }
protected void Page_Load(object sender, EventArgs e) { var clienteWcf = new CustomerClient(); var listaClientes = clienteWcf.Get10().ToList(); GridView1.DataSource = listaClientes; GridView1.DataBind(); }
protected void Page_Load(object sender, EventArgs e) { if (!String.IsNullOrWhiteSpace(CustomerID.Text)) { var customerID = Int32.Parse(CustomerID.Text); var cliente = new CustomerClient(); var c = cliente.Get(customerID); if (c != null) FirstName.Text = c.FirstName; } }