public async Task <IActionResult> PutTodoItem(int id, CustomerItems customerItems) { if (id != customerItems.id) { return(BadRequest()); } _context.Entry(customerItems).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!CustomerExists(id)) { return(NotFound()); } else { throw; } } return(Ok(customerItems)); // This is where we set our put method, you can add customers // to the database through postman. }
private void Page_Loaded(object sender, RoutedEventArgs e) { DataGrid_Main.DataContext = CustomerItems; var context = new KhorshidContext(); CustomerItems.Clear(); context.Customers.ToList().ForEach(c => CustomerItems.Add(c)); SearchBox.Focus(); }
private void SearchTextBox_ApplyModification() { if (SearchBox.Text.Trim()?.Length == 0) { var context = new KhorshidContext(); CustomerItems.Clear(); context.Customers.ToList().ForEach(c => CustomerItems.Add(c)); } else { string term = SearchBox.Text.Replace("آ", "ا"); SearchEngine.ApplySearchOnCollection(term, CustomerItems); } }
private async Task DeleteCustomerAsync() { await Task.Run(() => { foreach (var customerWrapper in CustomerItems.ToList()) { if (customerWrapper.IsSelected) { if (customerWrapper != null) { string Name = customerWrapper.FirstName + " " + customerWrapper.LastName; customerWrapper.IsDeleted = true; _clientService.Delete <Customer>(customerWrapper.Model); CustomerItems.Remove(customerWrapper); _eventAggregator.GetEvent <StatusBarEvent>().Publish(Name + "was deleted"); Thread.Sleep(1000); } } } }); }
public void InsertCustomerItem(int cusID, int classId) { Customer cs = new Customer(); //get the product id by class ID string sql = "select Fin_Product.ID,Fin_Product.Price from Fin_Product Inner join Int_EdyProduct on Fin_Product.ID = Int_EdyProduct.ProductID Inner join Std_Class on Std_Class.EdyID = Int_EdyProduct.EdyID Where Std_Class.ID = " + classId.ToString(); DataTable intDT = DataAccess.ExecuteSQLQuery(sql); int CIId = 0; if (intDT != null && intDT.Rows != null && intDT.Rows.Count > 0) { CustomerItems ci = new CustomerItems(); ci.CustomerID = cusID; ci.ProductID = int.Parse(intDT.Rows[0]["ID"].ToString()); ci.Price = Decimal.Parse(intDT.Rows[0]["Price"].ToString()); CIId = cs.addCustomerItem(int.Parse(intDT.Rows[0]["ID"].ToString()), Decimal.Parse(intDT.Rows[0]["Price"].ToString()), cusID); } //save the relation table sql = "Insert into Int_StdCustomer(StdID,CusID,CustItemID) Values(" + _id.ToString() + "," + cusID.ToString() + "," + CIId.ToString() + ")"; DataAccess.ExecuteSQLNonQuery(sql); //return sql; }