public ActionResult Create(Customer customer)
        {
            _repo.Context.Add<Customer>(customer);

            _repo.Context.Commit();

            return RedirectToAction("Index", "Customer");
        }
        public ActionResult Create(Customer customer)
        {
            customer.DateCreated = DateTime.Now;
            customer.DateUpdated = DateTime.Now;

            repo.Context.Add<Customer>(customer);

            repo.Context.Commit();

            return RedirectToAction("Index", "Customer");
        }
        public CustomerController(Customer customer)
        {
            this.Customer = customer;

            if (serverConnection == true)
                connectionString = "Data Source=tcp:j0xk94jyew.database.windows.net,1433;Initial Catalog=CustDatabase2;User ID=DatabaseUser112@j0xk94jyew;Password=13579DataPass!";
            else
                connectionString = "Server=.;Database=SimpleCustomerDatabase_db;Integrated Security=true";

            MappingConfig mappingConfig = new MappingConfig();
            DataContext context = new DataContext(connectionString, mappingConfig);
            repo = new Repository(context);
        }
Example #4
0
 private static void CreateDummyCustomer2()
 {
     instance = new Customer()
     {
         FirstName = "Bad",
         LastName = "Guy",
         Email = "*****@*****.**",
         PhoneNumber = "214.555.1212",
         CompanyName = "Company Work",
         CompanyStreet1 = "1233 Victory Way",
         CompanyStreet2 = "Suite 400",
         CompanyCity = "Addison",
         CompanyState = "TX",
         CompanyPostalCode = "75001",
     };
 }
Example #5
0
 private static void CreateDummyCustomer1()
 {
     instance = new Customer()
         {
             FirstName = "James",
             LastName = "Bond",
             Email = "*****@*****.**",
             PhoneNumber = "214.555.1212",
             CompanyName = "Company Work",
             CompanyStreet1 = "2525 Alta Vista Dr.",
             CompanyStreet2 =  "Suite 400",
             CompanyCity = "Addison",
             CompanyState = "TX",
             CompanyPostalCode = "75087",
         };
 }
        public ActionResult Create(Customer customer)
        {
            repo.Context.Add<Customer>(customer);

            repo.Context.Commit();

            return RedirectToAction("Index","Customer");

            //try
            //{
            //    // TODO: Add insert logic here

            //    return RedirectToAction("Index");
            //}
            //catch
            //{
            //    return View();
            //}
        }
        public ActionResult Edit(int id, Customer customer)
        {
            Customer originalCustomer = repo.Find(new FindById(id));

            originalCustomer.FirstName = customer.FirstName;
            originalCustomer.LastName = customer.LastName;
            originalCustomer.CompanyName = customer.CompanyName;
            originalCustomer.Email = customer.Email;
            originalCustomer.PhoneNumber = customer.PhoneNumber;
            originalCustomer.CompanyStreet1 = customer.CompanyStreet1;
            originalCustomer.CompanyStreet2 = customer.CompanyStreet2;
            originalCustomer.CompanyCity = customer.CompanyCity;
            originalCustomer.CompanyState = customer.CompanyState;
            originalCustomer.CompanyPostalCode = customer.CompanyPostalCode;

            repo.Context.Commit();

            return RedirectToAction("Index");

            //try
            //{
            //    // TODO: Add update logic here

            //    return RedirectToAction("Index");
            //}
            //catch
            //{
            //    return View();
            //}
        }
        public static List<Customer> CreateDummyCustomerModel()
        {
            var customers = new List<Customer>();

            var customer1 = new Customer()
            {
                FirstName = "Jim",
                LastName = "Bob",
                Email = "*****@*****.**",
                CompanyName = "Jim Bob's Granite Emporium",
                PhoneNumber = "222.333.3322",
                CompanyStreet1 = "Jim Bob Street",
                CompanyStreet2 = "Suite 2001",
                CompanyCity = "Addison",
                CompanyState = "TX",
                CompanyPostalCode = "77443"

            };

            var customer2 = new Customer()
            {
                FirstName = "Phone",
                LastName = "Booth",
                Email = "*****@*****.**",
                CompanyName = "Jim Bob's Granite Emporium",
                PhoneNumber = "222.333.3322",
                CompanyStreet1 = "Jim Bob Street",
                CompanyStreet2 = "Suite 2001",
                CompanyCity = "Addison",
                CompanyState = "TX",
                CompanyPostalCode = "77443"

            };

            var customer3 = new Customer()
            {
                FirstName = "Radar",
                LastName = "Jenkins",
                Email = "*****@*****.**",
                CompanyName = "Jim Bob's Granite Emporium",
                PhoneNumber = "222.333.3322",
            };

            var customer4 = new Customer()
            {
                FirstName = "Timothy",
                LastName = "Jenkins",
                Email = "*****@*****.**",
                CompanyName = "Jim Bob's Granite Emporium",
                PhoneNumber = "222.333.3322",
                CompanyStreet1 = "ABC Way",
                CompanyStreet2 = "Suite 2001",
                CompanyCity = "Addison",
                CompanyState = "TX",
                CompanyPostalCode = "77443"

            };

            var customer5 = new Customer()
            {
                FirstName = "Handy",
                LastName = "Sands",
                Email = "*****@*****.**",
                CompanyName = "Jim Bob's Granite Emporium",
                PhoneNumber = "222.333.3322",
                CompanyStreet1 = "Jim Bob Street",
                CompanyStreet2 = "Suite 2001",
                CompanyCity = "Addison",
                CompanyState = "TX",
                CompanyPostalCode = "77443"

            };

            customers.Add(customer1);
            customers.Add(customer2);
            customers.Add(customer3);
            customers.Add(customer4);
            customers.Add(customer5);

            return customers;
        }