private static void AddCustomer(Customer customer)
 {
     using (var repo = new CustomerRepo())
     {
         repo.Add(customer);
     }
 }
Пример #2
0
        private void btncomplete_Click(object sender, EventArgs e)
        {
            Customer customer = new Customer();
            Order    order    = new Order();

            customer.CustomerName    = txtcname.Text;
            customer.CustomerSurname = txtcsname.Text;

            crepo.Add(customer);

            order.Customer   = customer;
            order.CustomerID = customer.CustomerID;

            orepo.Add(order);


            foreach (Product item in ((MainMenu)Mainmenu).GetProduct())
            {
                OrderDetail orderDetail = new OrderDetail();

                orderDetail.OrderID = order.OrderID;
                //orderDetail.Product = item;
                orderDetail.ProductID = item.ProductID;
                orderDetail.Quantity  = 1;
                odrepo.Add(orderDetail);

                prepo.Update(item);
            }

            MessageBox.Show("Your Order is Completed. Total Price : " + txtPrice.Text);
        }
Пример #3
0
 private static void AddNewRecord(Customer cust)
 {
     using (var repo = new CustomerRepo())
     {
         repo.Add(cust);
     }
 }
        private void btnAdd_Click(object sender, EventArgs e)
        {
            cus.CustomerName    = txtCname.Text;
            cus.CustomerSurname = txtCsName.Text;


            if (chbStandart.Checked)
            {
                cus.CustomerType = 0;
            }
            else if (chbStudent.Checked)
            {
                cus.CustomerType = (CustomerType)1;
            }
            else if (chbChild.Checked)
            {
                cus.CustomerType = (CustomerType)2;
            }
            else if (chbOldAge.Checked)
            {
                cus.CustomerType = (CustomerType)3;
            }
            if (chbMale.Checked)
            {
                cus.GenderType = (GenderType)0;
            }
            else if (chbFemale.Checked)
            {
                cus.GenderType = (GenderType)1;
            }
            if (checkBox1.Checked)
            {
                ord.AirPlaneStatus = 0;
            }
            else if (checkBox2.Checked)
            {
                ord.AirPlaneStatus = (AirPlaneStatus)1;
            }

            crepo.Add(cus);

            requestform = Application.OpenForms["RequestForm"];
            Tour item = new Tour();

            item = ((RequestForm)requestform).GetTour();

            ListViewItem li = new ListViewItem();

            li.Text = item.TourName;
            li.SubItems.Add(cus.CustomerName + "" + cus.CustomerSurname);
            li.SubItems.Add(cus.GenderType.ToString());
            li.SubItems.Add(cus.CustomerType.ToString());
            li.SubItems.Add(PriceCalculator.GetPrice(item.Price, cus.CustomerType, ord.AirPlaneStatus).ToString());
            li.SubItems.Add(ord.AirPlaneStatus.ToString());

            lstSalesOperations.Items.Add(li);
        }
Пример #5
0
        public JsonResult Register(Customer customer)
        {
            JsonResultModel m = new JsonResultModel();

            if (ModelState.IsValid)
            {
                var c = CustomerRepo.GetCustomer(customer);
                if (c == null)
                {
                    CustomerRepo.Add(customer);
                    m.IsSuccess = true;
                }
            }
            return(Json(m, JsonRequestBehavior.AllowGet));
        }
        public ActionResult Register(Customer customer)
        {
            if (ModelState.IsValid)
            {
                CustomerRepo.Add(customer);
                Session["Email"]    = customer.Email;
                Session["Customer"] = customer;

                return(RedirectToAction("Index", "Home"));
            }
            else
            {
                ViewBag.Message = "Hata";
            }
            return(View());
        }
Пример #7
0
        public void ShouldGetOrderWithDetails()
        {
            ExecuteInATransaction(RunTheTest);
            void RunTheTest()
            {
                ResetContext();
                SampleDataInitializer.ClearData(Context);
                CreateCategoryAndProducts();
                var cust = new Customer()
                {
                    EmailAddress = "*****@*****.**",
                    FullName     = "Ful Name",
                    Password     = "******"
                };
                var order = new Order
                {
                    OrderDate = DateTime.Now,
                    ShipDate  = DateTime.Now
                };
                var product     = Context.Products.FirstOrDefault();
                var orderDetail = new OrderDetail
                {
                    ProductNavigation = product,
                    UnitCost          = 12.99M,
                    Quantity          = 1
                };

                order.OrderDetails.Add(orderDetail);
                cust.Orders.Add(order);
                ICustomerRepo custRepo = new CustomerRepo(Context);

                custRepo.Add(cust);
                Context.CustomerId = cust.Id;
                Assert.NotNull(Context.Customers.FirstOrDefault());
                Assert.NotNull(Context.Orders.FirstOrDefault());
                Assert.NotNull(Context.OrderDetails.FirstOrDefault());

                var orderRepo = new OrderRepo(Context, new OrderDetailRepo(Context));
                var record    = orderRepo.GetOneWithDetails(1);
                var foo       = "foo";
            }
        }
        public ActionResult Create([Bind(Include = "Id,客戶名稱,統一編號,電話,傳真,地址,Email,客戶分類")] 客戶資料 客戶資料)
        {
            if (ModelState.IsValid)
            {
                CustomerRepo.Add(客戶資料);
                CustomerRepo.UnitOfWork.Commit();
                return(RedirectToAction("Index"));
            }
            var items = (from p in classification
                         select p.Key)
                        .Distinct()
                        .OrderBy(p => p)
                        .Select(p => new SelectListItem()
            {
                Text  = classification[p].ToString(),
                Value = p.ToString()
            });

            ViewBag.客戶分類 = new SelectList(items, "Value", "Text");
            return(View(客戶資料));
        }
        public async Task <ActionResult <Customer> > PostCustomer(Customer customers)
        {
            //return Ok(await _customerRepo.Add(customers));
            try
            {
                if (customers == null)
                {
                    return(BadRequest());
                }

                var createdObj = await _customerRepo.Add(customers);

                return(CreatedAtAction(nameof(GetCustomer), new { id = createdObj.Id }, createdObj));
            }
            catch (Exception)
            {
                return(StatusCode(StatusCodes.Status500InternalServerError, "Error retreiving data from DB"));

                throw;
            }
        }
Пример #10
0
        public void ShouldAddCustomerWithRepo()
        {
            var cust = new Customer {
                Name = "Best Brakes", Address1 = "182 Arrow Ave", Address2 = "Suite B", City = "Chino", State = "CA", PointOfContact = "Jon Jay", PrimaryPhone = "9095551212", SecondaryPhone = "9095551313", EmailAddress = "*****@*****.**"
            };

            _repo.Add(cust, false);
            //Assert.AreEqual(EntityState.Added, _db.Entry(cust).State);
            Assert.IsTrue(cust.Id == 0);
            Assert.IsNull(cust.TimeStamp);
            _repo.SaveChanges();
            // Assert.AreEqual(EntityState.Unchanged, _db.Entry(cust).State);
            //Assert.IsTrue(driver.Id > 0);
            Assert.IsNotNull(cust.TimeStamp);
            Assert.IsNotNull(cust.DateCreated);
            Assert.IsNotNull(cust.DateModified);
            Assert.IsNotNull(cust.UserCreated);
            Assert.IsNotNull(cust.UserModified);
            Assert.AreEqual(1, _repo.Count);
        }
Пример #11
0
        protected void btnAddCustomer_Click(object sender, EventArgs e)
        {
            var selectedPlan = new PlanRepo().GetAll().Where(x => x.PlanName == cboPlan.SelectedValue).FirstOrDefault();
            //var plan = new PlanRepo().ExecuteQuery($"select planID from plan where planname = {cboPlan.SelectedValue};");


            var customer = new Customer
            {
                CustName  = txtCustomerName.Text,
                CustEmail = txtCustomerEmail.Text,
                PlanID    = selectedPlan.PlanID
            };

            var repo = new CustomerRepo();

            int returnVal = repo.Add(customer);

            panelDisplayCustomers.Visible = true;
            gridViewCustomers.Visible     = true;
            panelAddCustomer.Visible      = false;
            lblShowCustomers.Text         = "Customer successfully added. Here is the updated list:";
        }
Пример #12
0
 public void Add(SQLiteConnection connection, Customer customer)
 {
     CustomerRepo.Add(connection, customer);
 }
 public bool Add(Customer customer)
 {
     return(_customerRepo.Add(customer));
 }
Пример #14
0
 public void AddCustomer(Customer customer)
 {
     customerRepo.Add(customer);
 }
Пример #15
0
 public bool Add(int id, string name, string address, int contact)
 {
     return(_customerRepo.Add(id, name, address, contact));
 }