public IHttpActionResult DeleteCustomer(string token, int userId, int id) { if (!ApplicationHelper.IsTokenValid(token, userId)) { return(Content(HttpStatusCode.BadRequest, "BadRequest")); } var customerDb = CustomersLogic.GetCustomer(id); if (customerDb == null) { return(Content(HttpStatusCode.NotFound, "NotFound")); } var result = CustomersLogic.DeleteCustomer(id); if (!result.Success) { ApplicationHelper.Log(result.Message); } return(result.Success ? Content(HttpStatusCode.OK, "OK") : Content(HttpStatusCode.InternalServerError, result.Message)); }
public static ResponseDTO <CustomersDTO> RegisterCustomer(CustomersDTO customer) { var newCustomerLogic = new CustomersLogic(); var response = newCustomerLogic.CustomerExecute(new RequestDTO <CustomersDTO> { Item = customer }); return(response); }
public IHttpActionResult GetCustomer(string token, int userId, int id) { if (!ApplicationHelper.IsTokenValid(token, userId)) { return(Content(HttpStatusCode.BadRequest, "BadRequest")); } var customer = CustomersLogic.GetCustomer(id); if (customer == null) { return(Content(HttpStatusCode.NotFound, "NotFound")); } return(Content(HttpStatusCode.OK, customer)); }
public IHttpActionResult CreateCustomer(string token, int userId, Customer customer) { if (!ModelState.IsValid || !ApplicationHelper.IsTokenValid(token, userId)) { return(Content(HttpStatusCode.BadRequest, "BadRequest")); } var result = CustomersLogic.CreateCustomer(customer); if (!result.Success) { ApplicationHelper.Log(result.Message); } return(result.Success ? Content(HttpStatusCode.OK, "OK") : Content(HttpStatusCode.InternalServerError, result.Message)); }
private void btnDelete_Click(object sender, RoutedEventArgs e) { try { selectedCustomer = dgCustomers.SelectedItem != null ? dgCustomers.SelectedItem as Model.Customer : null; if (selectedCustomer != null) { if (MessageBox.Show("ยืนยันที่จะลบข้อมูลผู้เช่า " + selectedCustomer.ContactName, "ยืนยันการลบข้อมูล", MessageBoxButton.OKCancel, MessageBoxImage.Warning) == MessageBoxResult.OK) { CustomersLogic cl = new CustomersLogic(); cl.DaleteCustomer(selectedCustomer); dgCustomers.ItemsSource = new CustomersLogic().GetCustomers(); } } else { MessageBox.Show("กรุณาเลือกข้อมูลที่จะลบ", "เกิดข้อผิดพลาด", MessageBoxButton.OK, MessageBoxImage.Error); } } catch (Exception ex) { MessageBox.Show(ex.Message, "เกิดข้อผิดพลาด", MessageBoxButton.OK, MessageBoxImage.Error); } }
public void viewCustomersMenu() { int input = 0; Console.WriteLine(" "); Console.WriteLine(" "); Console.WriteLine(" "); Console.WriteLine(" +================================================================+"); Console.WriteLine(" | |"); Console.WriteLine(" | CUSTOMERS MENU |"); Console.WriteLine(" | |"); Console.WriteLine(" +================================================================+"); Console.WriteLine(" +----------------------------------------------------------------+"); Console.WriteLine(" | [1] VIEW CUSTOMER CATALOG |"); Console.WriteLine(" +----------------------------------------------------------------+"); Console.WriteLine(" +----------------------------------------------------------------+"); Console.WriteLine(" | [2] CREATE AN ACCOUNT |"); Console.WriteLine(" +----------------------------------------------------------------+"); Console.WriteLine(" +----------------------------------------------------------------+"); Console.WriteLine(" | [3] FIND AN ACCOUNT |"); Console.WriteLine(" +----------------------------------------------------------------+"); Console.WriteLine(" +----------------------------------------------------------------+"); Console.WriteLine(" | [3] DELETE ACCOUNT |"); Console.WriteLine(" +----------------------------------------------------------------+"); Console.WriteLine(" "); Console.WriteLine(" "); Console.WriteLine(" "); Console.WriteLine(" +----------------------------------------------------------------+"); Console.WriteLine(" | [5] RETURN TO MAIN MENU |"); Console.WriteLine(" +----------------------------------------------------------------+"); input = Int32.Parse(Console.ReadLine()); var customer = new CustomersLogic(); switch (input) { case 1: Console.Clear(); Console.WriteLine(" +----------------------------------------------------------------+"); Console.WriteLine(" | CREATE A ACCOUNT |"); Console.WriteLine(" +----------------------------------------------------------------+"); customer.GetCustomers(); break; case 2: Console.Clear(); Console.WriteLine(" +----------------------------------------------------------------+"); Console.WriteLine(" | CREATE A ACCOUNT |"); Console.WriteLine(" +----------------------------------------------------------------+"); customer.Add(); break; case 3: Console.Clear(); Console.WriteLine(" +----------------------------------------------------------------+"); Console.WriteLine(" | FIND AN ACCOUNT |"); Console.WriteLine(" +----------------------------------------------------------------+"); customer.GetCustomerById(); break; case 4: Console.Clear(); Console.WriteLine(" +----------------------------------------------------------------+"); Console.WriteLine(" | DELETE AN ACCOUNT |"); Console.WriteLine(" +----------------------------------------------------------------+"); customer.Delete(); break; default: Console.Clear(); var mainmenu = new MainMenu(); mainmenu.viewMainMenu(); break; } }