コード例 #1
0
        public ActionResult delete(int id)
        {
            var query = (from customerdata in customerObject.tblCustomers
                         where customerdata.id == id
                         select customerdata).Single();

            customerObject.tblCustomers.DeleteOnSubmit(query);
            customerObject.SubmitChanges();
            Response.Redirect("/customer/index");
            return(View());
        }
コード例 #2
0
        public static void Delete(string customerID)
        {
            CustomerDataContext context = new CustomerDataContext();

            Customer cust = context.Customers.Single(c => c.CustomerID == customerID);

            context.Customers.DeleteOnSubmit(cust);
            context.SubmitChanges();
        }
コード例 #3
0
        public ActionResult delete(int id)
        {
            var role = RouteData.Values["role"].ToString();

            ViewBag.role   = role;
            ViewBag.layout = "~/Views/Shared/_" + role + "Layout.cshtml";

            var query = (from customerdata in customerObject.tblCustomers
                         where customerdata.id == id
                         select customerdata).Single();

            customerObject.tblCustomers.DeleteOnSubmit(query);
            customerObject.SubmitChanges();
            var redirectUrl = "/profile/" + role + "/customer/index";

            Response.Redirect(redirectUrl);
            return(View());
        }
コード例 #4
0
        public static Customer Create(Customer newCustomer)
        {
            CustomerDataContext context = new CustomerDataContext();

            context.Customers.InsertOnSubmit(newCustomer);
            context.SubmitChanges();

            Customer cust = context.Customers.Single(c => c.CustomerID == newCustomer.CustomerID);

            return(cust);
        }
コード例 #5
0
        public static void Update(Customer customer, string customerID)
        {
            CustomerDataContext context = new CustomerDataContext();

            Customer cust = context.Customers.Single(c => c.CustomerID == customer.CustomerID);

            cust.CustomerID   = customer.CustomerID;
            cust.Address      = customer.Address;
            cust.City         = customer.City;
            cust.CompanyName  = customer.CompanyName;
            cust.ContactName  = customer.ContactName;
            cust.ContactTitle = customer.ContactTitle;
            cust.Country      = customer.Country;
            cust.Fax          = customer.Fax;
            cust.Phone        = customer.Phone;
            cust.PostalCode   = customer.PostalCode;
            cust.Region       = customer.Region;

            context.SubmitChanges();
        }