public ActionResult Delete(short id, Customer formCust) { try { var cust = context.GetCustomerByID((short)id); context.Customers.DeleteOnSubmit(cust); context.SubmitChanges(); return RedirectToAction("Index"); } catch { return View(); } }
public ActionResult Create(Customer cust) { try { // Don't need this with Linq - is that awesome or what? //cust.CustomerNum = Convert.ToInt16(collection.GetValue("CustomerNum").ToString()); //cust.CompanyName = collection.GetValue("CompanyName").ToString(); //cust.BillToAddr1 = collection.GetValue("BillToAddr1").ToString(); //cust.BillToAddr2 = collection.GetValue("BillToAddr2").ToString(); //cust.BillToCity = collection.GetValue("BillToCity").ToString(); //cust.BillToState = collection.GetValue("BillToState").ToString(); //cust.BillToPhone = collection.GetValue("BillToPhone").ToString(); //cust.email = collection.GetValue("email").ToString(); context.Customers.InsertOnSubmit(cust); context.SubmitChanges(); return RedirectToAction("Index"); } catch (Exception biteMeIfNotUsed) { return View(); } }
public ActionResult Edit(Customer formCust) { try { // TODO: Add update logic here var contextCust = context.GetCustomerByID((short)formCust.CustomerNum); contextCust.CompanyName = formCust.CompanyName; contextCust.BillToAddr1 = formCust.BillToAddr1; contextCust.BillToAddr2 = formCust.BillToAddr2; contextCust.BillToCity = formCust.BillToCity; contextCust.BillToState = formCust.BillToState; contextCust.BillToZip5 = formCust.BillToZip5; contextCust.BillToZip4 = formCust.BillToZip4; contextCust.BillToPhone = formCust.BillToPhone; contextCust.BillToFax = formCust.BillToFax; contextCust.email = formCust.email; contextCust.ShipToAddr1 = formCust.ShipToAddr1; contextCust.ShipToAddr2 = formCust.ShipToAddr2; contextCust.ShipToCity = formCust.ShipToCity; contextCust.ShipToState = formCust.ShipToState; contextCust.ShipToZip5 = formCust.ShipToZip5; contextCust.ShipToZip4 = formCust.ShipToZip4; contextCust.ShipToPhone = formCust.ShipToPhone; contextCust.ShipToFax = formCust.ShipToFax; context.SubmitChanges(); return RedirectToAction("Index"); } catch (Exception e2) { return View(); } }
partial void DeleteCustomer(Customer instance);
partial void UpdateCustomer(Customer instance);
partial void InsertCustomer(Customer instance);