public List <Customer> Get() { //var MesCustomers = new JavaScriptSerializer().Serialize(ClassConnection.GetCustomer()); //var listCustomer = ClassConnection.GetCustomer(); return(ServiceCustomer.GetCustomer()); }
public IActionResult AddService(ServiceViewModel obj) { obj.Note.Category = "Service Notes"; int customerID = obj.Note.CustomerId; _db.Notes.Add(obj.Note); _db.SaveChanges(); // int customerID = obj.CustomerId; var record = _db.ServiceCustomers.FirstOrDefault(c => c.CustomerId == customerID); int ServiceID = record.Id; var ServiceCust = new ServiceCustomer(); ServiceCust = _db.ServiceCustomers.Find(ServiceID); if (obj.Note.Date == DateTime.MinValue) { obj.Note.Date = DateTime.Now; } ServiceCust.LastServiceDate = obj.Note.Date; ServiceCust.NextServiceDate = obj.Note.Date.AddMonths(6); _db.ServiceCustomers.Update(ServiceCust); // _db.Notes.Add(obj); _db.SaveChanges(); return(RedirectToAction("UpdateServiceContract", new { ServiceCust.Id })); }
public ServiceCustomer GetCustomerById(int id) { ServiceCustomer serviceCustomer = null; using (SqlConnection connection = new SqlConnection(_connectionString)) { connection.Open(); using (SqlCommand cmdGetCustomerByEmail = connection.CreateCommand()) { cmdGetCustomerByEmail.CommandText = "SELECT customerId, name, address, zipCode, phoneNo, passwordHash, salt, email FROM Customer WHERE customerId = @CustomerIDD"; cmdGetCustomerByEmail.Parameters.AddWithValue("CustomerIDD", id); SqlDataReader customerReader = cmdGetCustomerByEmail.ExecuteReader(); if (customerReader.Read()) { serviceCustomer = new ServiceCustomer(); serviceCustomer.CustomerId = customerReader.GetInt32(customerReader.GetOrdinal("customerId")); serviceCustomer.Name = customerReader.GetString(customerReader.GetOrdinal("name")); serviceCustomer.Address = customerReader.GetString(customerReader.GetOrdinal("address")); serviceCustomer.ZipCode = customerReader.GetInt32(customerReader.GetOrdinal("zipCode")); serviceCustomer.PhoneNo = customerReader.GetString(customerReader.GetOrdinal("phoneNo")); serviceCustomer.Hash = customerReader.GetString(customerReader.GetOrdinal("passwordHash")); serviceCustomer.Salt = customerReader.GetString(customerReader.GetOrdinal("salt")); serviceCustomer.Email = customerReader.GetString(customerReader.GetOrdinal("email")); serviceCustomer.City = GetCityFromZipCode(serviceCustomer.ZipCode); } } } return(serviceCustomer); }
public CustomerWindow(Boolean logIn, String userEmail) { InitializeComponent(); UniversalFunctions.setUpWindow(this); this.isUserSignedIn = false; DataGridProducts.DataContext = ServiceProducts.getProductsToDisplay().DefaultView; btnShowProducts.Visibility = Visibility.Hidden; btnShowCart.IsEnabled = isUserSignedIn; btnOrderHistory.IsEnabled = isUserSignedIn; this.isUserSignedIn = logIn; currentUserEmail = userEmail; if (this.isUserSignedIn) { btnCustomerLogInMenu.Visibility = Visibility.Hidden; lblSingedInAs.Content = "Signed in as " + ServiceCustomer.getNameFromEmail(userEmail); btnShowCart.IsEnabled = isUserSignedIn; btnOrderHistory.IsEnabled = isUserSignedIn; } else { lblSingedInAs.Content = "Login Failed"; } }
public IActionResult CreateServiceContract(ServiceCustomer obj) { int id = obj.CustomerId; _db.ServiceCustomers.Add(obj); _db.SaveChanges(); return(RedirectToAction("ViewCustomer", "Customers", new { id })); }
public Customer GetCustomer(int id) { Customer customerToReturn; using (CustomerServiceClient proxy = new CustomerServiceClient()) { ServiceCustomer customer = proxy.GetCustomer(id); customerToReturn = Converter.ConvertFromServiceCustomer(customer); } return(customerToReturn); }
public int InsertCustomer(Customer customer) { int id; using (CustomerServiceClient proxy = new CustomerServiceClient()) { ServiceCustomer customerToInsert = Converter.ConvertToServiceCustomer(customer); id = proxy.InsertCustomer(customerToInsert); } return(id); }
public int InsertCustomer(ServiceCustomer customer) { string hash; string salt; GenerateSaltedHash(customer.Password, out hash, out salt); customer.Hash = hash; customer.Salt = salt; return(dataCustomer.InsertCustomer(customer)); }
public IActionResult CreateServiceNotes(ServiceViewModel obj) { //var ServiceCust = new ServiceCustomer(); //ServiceCust = _db.ServiceCustomers.Find(obj.Note.CustomerId); obj.Note.Category = "Contract Notes"; _db.Notes.Add(obj.Note); _db.SaveChanges(); var ServiceCust = new ServiceCustomer(); ServiceCust = _db.ServiceCustomers.FirstOrDefault(c => c.CustomerId == obj.Note.CustomerId); return(RedirectToAction("UpdateServiceContract", new { ServiceCust.Id })); }
public ServiceCustomer VerifyLogin(string enteredPassword, string email) { ServiceCustomer serviceCustomer = null; bool success = false; serviceCustomer = dataCustomer.GetCustomerByEmail(email); if (serviceCustomer != null) { success = VerifyPassword(enteredPassword, serviceCustomer.Hash, serviceCustomer.Salt); if (success == false) { serviceCustomer = null; } } return(serviceCustomer); }
private void BtnRegisterUser_Click(object sender, RoutedEventArgs e) { CustomerWindow customerWindow; Boolean isRegistrartionSuccessful = ServiceCustomer.registerNewUser(txtLogInEmail.Text, txtLogInPswrd.Text, txtRegisterFirstName.Text, txtRegisterLastName.Text, txtRegisterAddress.Text, txtRegisterCity.Text, "country", int.Parse(txtRegisterPhoneNumber.Text)); if (isRegistrartionSuccessful) { customerWindow = new CustomerWindow(true, txtRegisterFirstName.Text); } else { customerWindow = new CustomerWindow(false, ""); } this.Close(); customerWindow.Show(); }
// #region Create Contract public IActionResult CreateServiceContract(int id) { var ContractVM = new ServiceCustomer(); if (id == 0) { return(NotFound()); } else { ContractVM.CustomerId = id; } if (ContractVM == null) { return(NotFound()); } return(View(ContractVM)); }
public int UpdateCustomer(ServiceCustomer customer) { int rowsAffected; using (SqlConnection connection = new SqlConnection(_connectionString)) { connection.Open(); using (SqlCommand cmdUpdateCustomer = connection.CreateCommand()) { cmdUpdateCustomer.CommandText = "UPDATE Customer SET name = @name, address = @address, zipCode = @zipCode, phoneNo = @phoneNo WHERE customerId = @customerId"; cmdUpdateCustomer.Parameters.AddWithValue("name", customer.Name); cmdUpdateCustomer.Parameters.AddWithValue("address", customer.Address); cmdUpdateCustomer.Parameters.AddWithValue("zipCode", customer.ZipCode); cmdUpdateCustomer.Parameters.AddWithValue("phoneNo", customer.PhoneNo); rowsAffected = cmdUpdateCustomer.ExecuteNonQuery(); } } return(rowsAffected); }
public int VerifyCustomerLogin(string password, string email) { int customerID; using (CustomerServiceClient proxy = new CustomerServiceClient()) { ServiceCustomer customer = proxy.VerifyLogin(password, email); if (customer != null) { customerID = customer.CustomerId; } else { customerID = -1; } } return(customerID); }
public void InsertOrderTest() { //Arrange DataProduct dataProduct = new DataProduct(); DataCustomerOrder dataCustomerOrder = new DataCustomerOrder(); ServiceCustomer customer = new ServiceCustomer(); customer.Name = "Peter J."; customer.Address = "Sofiendalsvej"; customer.ZipCode = 9000; customer.PhoneNo = "12345678"; ServiceProduct product = new ServiceProduct(); product = dataProduct.GetProductById(4); ServiceProductLine productLine = new ServiceProductLine(); productLine.Amount = 1; productLine.SubTotal = product.Price; productLine.Product = product; ServiceCustomerOrder order = new ServiceCustomerOrder(); order.FinalPrice = productLine.SubTotal; order.Status = "Active"; order.DateOrder = DateTime.Now; order.PaymentMethod = 1; order.DiscountCode = null; List <ServiceProductLine> productLines = new List <ServiceProductLine>(); productLines.Add(productLine); order.ShoppingCart = productLines; //Act bool success = dataCustomerOrder.FinishCheckout(order); //Assert Assert.IsTrue(success); }
private void BtnLogInCostumer_Click(object sender, RoutedEventArgs e) { CustomerWindow costumerWindow; // här vill vi kolla med db att man faktiskt har blivit inloggad. String userEmail = txtLogInEmail.Text; String password = txtLogInPswrd.Text; System.Diagnostics.Debug.WriteLine(" skickar med till db: " + userEmail); if (ServiceCustomer.isUserCredentialsCorrect(userEmail, password)) { costumerWindow = new CustomerWindow(true, userEmail); System.Diagnostics.Debug.WriteLine(" user can sign in "); } else { costumerWindow = new CustomerWindow(false, ""); System.Diagnostics.Debug.WriteLine(" user can not sign in "); } this.Close(); costumerWindow.Show(); }
public int InsertCustomer(ServiceCustomer customer) { int insertedId = -1; using (SqlConnection connection = new SqlConnection(_connectionString)) { connection.Open(); using (SqlCommand cmdInsertCustomer = connection.CreateCommand()) { cmdInsertCustomer.CommandText = "INSERT INTO Customer (name, address, zipCode, phoneNo, passwordHash, salt, email) OUTPUT INSERTED.customerId VALUES (@name, @address, @zipCode, @phoneNo, @passwordHash, @salt, @email)"; cmdInsertCustomer.Parameters.AddWithValue("name", customer.Name); cmdInsertCustomer.Parameters.AddWithValue("address", customer.Address); cmdInsertCustomer.Parameters.AddWithValue("zipCode", customer.ZipCode); cmdInsertCustomer.Parameters.AddWithValue("phoneNo", customer.PhoneNo); cmdInsertCustomer.Parameters.AddWithValue("passwordHash", customer.Hash); cmdInsertCustomer.Parameters.AddWithValue("salt", customer.Salt); cmdInsertCustomer.Parameters.AddWithValue("email", customer.Email); insertedId = (int)cmdInsertCustomer.ExecuteScalar(); } } return(insertedId); //This is a comment used for the report in systemudvikling. }
public int Delete(Guid customerId) { var customerService = new ServiceCustomer(); return(customerService.DeleteCustomers(customerId)); }
public IEnumerable <Customer> Get() { var customerService = new ServiceCustomer(); return(customerService.GetCustomers()); }
public int Post([FromBody] Customer customer) { var customerService = new ServiceCustomer(); return(customerService.PostCustomers(customer)); }
public void UpdateCustomer(ServiceCustomer customer) { dataCustomer.UpdateCustomer(customer); }
public void Delete(int id) { ServiceCustomer.DeleteCustomer(id); }
public void Put(int id, [FromBody] Customer customer) { customer.Id = id; ServiceCustomer.EditCustomer(customer); }
public void Post([FromBody] Customer customer) { ServiceCustomer.CreateCustomer(customer); }
private ServiceCustomer PostServiceCustomer( [RouteParam(ParameterIn.Path, Description = "The GUID that identifies the service")] string serviceGuid, [RouteParam(ParameterIn.Body)] ServiceCustomer customer) { return(customer); }
private ServiceCustomer PostServiceCustomer( [RouteParam(ParameterIn.Path, DefaultValue = "my-service")] string service, [RouteParam(ParameterIn.Body)] ServiceCustomer customer) { return(customer); }
public Customer Get(int id) { return(ServiceCustomer.GetCustomerByid(id)); }