public void AddShouldWork()
        {
            var productID = Guid.NewGuid();
            var product   = new Product(productID)
            {
                Price = new Price(5.0m, "EUR")
            };

            repo.Add(product);
            var rehydratedProduct = repo.GetByID(productID);

            rehydratedProduct.Price.Should().Be(product.Price);
            rehydratedProduct.Should().Be(product);
        }
예제 #2
0
        public async Task <IActionResult> Post([FromBody] Order order)
        {
            salesContext.Add(order);
            await salesContext.SaveChangesAsync();

            return(Created(order));
        }
예제 #3
0
 private void AddButton_Click(object sender, EventArgs e)
 {
     try
     {
         if ((firstNameBox.Text.ToString() == null || firstNameBox.Text.ToString() == "") ||
             (lastNameBox.Text.ToString() == null || lastNameBox.Text.ToString() == ""))
         {
             MessageBox.Show("Enter a first and last name.");
         }
         else
         {
             Customer customer = new Customer();
             customer.FirstName = firstNameBox.Text.ToString();
             customer.LastName  = lastNameBox.Text.ToString();
             customer.City      = cityBox.Text.ToString();
             customer.Country   = countryBox.Text.ToString();
             customer.Phone     = phoneBox.Text.ToString();
             salesContext.Add(customer);
             salesContext.SaveChanges();
             GetCustomers();
         }
     }
     catch (Exception addException)
     {
         MessageBox.Show(addException.Message, "exception has occurred");
     }
 }
예제 #4
0
 private void addbtn_Click(object sender, EventArgs e)
 {
     try
     {
         if ((txtfirst.Text.ToString().Trim() == null || txtfirst.Text.ToString().Trim() == "") ||
             (txtlast.Text.ToString().Trim() == null || txtlast.Text.ToString().Trim() == ""))
         {
             //if the required name fields are empty strings or null, do not add customer
             MessageBox.Show("First and Last Name are required fields.");
         }
         else
         {
             Customer customer = new Customer();
             customer.FirstName = txtfirst.Text.ToString().Trim();
             customer.LastName  = txtlast.Text.ToString().Trim();
             customer.City      = txtcity.Text.ToString().Trim();
             customer.Country   = txtcountry.Text.ToString().Trim();
             customer.Phone     = txtphone.Text.ToString().Trim();
             //take info in text boxes and put into a customer object to add
             ctx.Add(customer);
             ctx.SaveChanges();
             MessageBox.Show("Added new customer.");
             txtfirst.Text = txtlast.Text = txtcity.Text = txtcountry.Text = txtphone.Text = "";
             //clears out text boxes after entry
             getData();
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message, "Error");
     }
 }
예제 #5
0
        // metodo para inserir os dados na base

        public async Task InsertAsync(Seller obj)
        {
            _context.Add(obj);

            // confirmando a inserção
            await _context.SaveChangesAsync();
        }
예제 #6
0
        public async Task <IActionResult> Create([Bind("AddressId,AddressLine1,AddressLine2,City,StateProvince,CountryRegion,PostalCode,rowguid,ModifiedDate")] Address address)
        {
            if (ModelState.IsValid)
            {
                _context.Add(address);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(address));
        }
        public async Task <IActionResult> Create([Bind("Id,Name")] Department department)
        {
            if (ModelState.IsValid)
            {
                _context.Add(department);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(department));
        }
예제 #8
0
        public async Task <IActionResult> Create([Bind("Id,CompanyName,ContactName,ContactTitle,City,Country,Phone,Fax")] Supplier supplier)
        {
            if (ModelState.IsValid)
            {
                _context.Add(supplier);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(supplier));
        }
예제 #9
0
        public async Task <IActionResult> Create([Bind("id,name,quantity,price,detail")] Product product)
        {
            if (ModelState.IsValid)
            {
                _context.Add(product);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(product));
        }
        public async Task <IActionResult> Create([Bind("Id,FirstName,LastName,City,Country,Phone")] Customer customer)
        {
            if (ModelState.IsValid)
            {
                _context.Add(customer);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(customer));
        }
        public async Task <IActionResult> Create([Bind("Id,Date,Amount,Status")] SalesRecord salesRecord)
        {
            if (ModelState.IsValid)
            {
                _context.Add(salesRecord);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(salesRecord));
        }
예제 #12
0
        public async Task <IActionResult> Create([Bind("Id,ProductName,SupplierId,UnitPrice,Package,IsDiscontinued")] Product product)
        {
            if (ModelState.IsValid)
            {
                _context.Add(product);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["SupplierId"] = new SelectList(_context.Suppliers, "Id", "CompanyName", product.SupplierId);
            return(View(product));
        }
예제 #13
0
        public static void AddCust(string FirstName, string LastName, string city, string country, string phone)
        {
            Customer newCust = new Customer();

            newCust.FirstName = FirstName;
            newCust.LastName  = LastName;
            newCust.City      = city;
            newCust.Country   = country;
            newCust.Phone     = phone;
            CustomerData.Add(newCust);
            CustomerData.SaveChanges();
        }
예제 #14
0
        public static void addCust(string fName, string lName, string city, string country, string pNumber)
        {
            Customer addNewCust = new Customer();

            addNewCust.FirstName = fName;
            addNewCust.LastName  = lName;
            addNewCust.City      = city;
            addNewCust.Country   = country;
            addNewCust.Phone     = pNumber;
            salesContext.Add(addNewCust);
            salesContext.SaveChanges();
        }
예제 #15
0
        public static void addCustomer(string firstName, string lastName, string city, string country, string phone)
        {
            Customer newCust = new Customer();

            newCust.FirstName = firstName;
            newCust.LastName  = lastName;
            newCust.City      = city;
            newCust.Country   = country;
            newCust.Phone     = phone;
            sc.Add(newCust);
            sc.SaveChanges();
            Console.WriteLine("Customer added.");
        }
예제 #16
0
 private void addButton_Click(object sender, EventArgs e)
 {
     if (string.IsNullOrEmpty(firstNbox.Text.ToString()) || string.IsNullOrEmpty(lastNBox.Text.ToString()))
     {
         MessageBox.Show("Enter a First and Last name to continue.");
     }
     else
     {
         string city = null, country = null, phone = null;
         if (string.IsNullOrEmpty(cityBox.Text.ToString()))
         {
             city = null;
         }
         else
         {
             city = cityBox.Text.ToString();
         }
         if (string.IsNullOrEmpty(countryBox.Text.ToString()))
         {
             country = null;
         }
         else
         {
             country = countryBox.Text.ToString();
         }
         if (string.IsNullOrEmpty(phoneBox.Text.ToString()))
         {
             phone = null;
         }
         else
         {
             phone = phoneBox.Text.ToString();
         }
         SalesContext stx     = new SalesContext();
         var          newUser = new Customer
         {
             FirstName = firstNbox.Text.ToString(),
             LastName  = lastNBox.Text.ToString(),
             City      = city,
             Country   = country,
             Phone     = phone
         };
         stx.Add <Customer>(newUser);
         stx.SaveChanges();
         userData.DataSource         = stx.Customers.OrderBy(c => c.Id).ToList();
         userData.Columns[0].Visible = false;
         this.Close();
     }
 }
예제 #17
0
        public override void Seed(SalesContext db)
        {
            var rand = new Random();

            var name = RandomString(rand.Next(7, 40), Convert.ToBoolean(rand.Next(0, 1)));

            var email = RandomString(rand.Next(7, 40), Convert.ToBoolean(rand.Next(0, 1)));

            var creditCardNumber = RandomString(rand.Next(7, 40), Convert.ToBoolean(rand.Next(0, 1)));

            db.Add(new Customer
            {
                Name             = name,
                Email            = email,
                CreditCardNumber = creditCardNumber
            });
        }
예제 #18
0
        public override void Seed(SalesContext db)
        {
            var rand = new Random();

            var name = RandomString(rand.Next(7, 40), Convert.ToBoolean(rand.Next(0, 1)));

            var qunantity = rand.Next(0, 20);

            var price = rand.Next(0, 20);

            db.Add(new Product
            {
                Name     = name,
                Price    = price,
                Quantity = qunantity
            });
        }
예제 #19
0
 public async Task InsertAsync(Seller obj)
 {
     _context.Add(obj);
     await _context.SaveChangesAsync();
 }
예제 #20
0
 public async Task InsertAsync(Department department)
 {
     _context.Add(department);
     await _context.SaveChangesAsync();
 }
예제 #21
0
 public void Insert(Seller seller)
 {
     _context.Add(seller);
     _context.SaveChanges();
 }
예제 #22
0
 public void AddSale(Sale sale)
 {
     _salesContext.Add(sale);
     _salesContext.SaveChanges();
 }
예제 #23
0
 public void Insert(Seller obj)
 {
     _context.Add(obj);
     _context.SaveChanges();
 }