private void btnSaveO_Click(object sender, RoutedEventArgs e) { Order1 order = null; if (action == ActionState.New) { try { Customer1 customer = (Customer1)cmbCustomer1.SelectedItem; Inventory1 inventory = (Inventory1)cmbInventory1.SelectedItem; //instantiem Order entity order = new Order1() { CustId = customer.CustId, CarId = inventory.CarId }; //adaugam entitatea nou creata in context ctx.Order1.Add(order); customerViewSource.View.Refresh(); //salvam modificarile ctx.SaveChanges(); } catch (DataException ex) { MessageBox.Show(ex.Message); } } }
public IHttpActionResult PutCustomer(int id, Customer1 customer) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != customer.CustomerId) { return(BadRequest()); } db.Entry(customer).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!CustomerExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
internal static List <Customer1> AllCustomerType1() { try { SqlCommand command = new SqlCommand("AllCustomerType1"); DataSet ds = DBManager.selectQuery(command, "OIGAME_CONSULTORES_Test"); List <Customer1> customerList = new List <Customer1>(); DataTable dt = ds.Tables[0]; foreach (DataRow row in dt.Rows) { Customer1 c = new Customer1(); c.Id = int.Parse(row["Id"].ToString()); c.Description = row["Description"].ToString(); c.Passport = row["Passport"].ToString(); c.FirstName = row["FirstName"].ToString(); c.LastName = row["LastName"].ToString(); c.Active = bool.Parse(row["Active"].ToString()); customerList.Add(c); } return(customerList); } catch (Exception ex) { return(null); throw ex; } }
public Customer1 GetCustomer(int id) { CustReposit rep = new CustReposit(); Customer1 c = rep.FindCustomer(id); return(c); }
// right clicking here creates a form atomagically. public IActionResult Create(CustomerViewModel customer) { try { if (ModelState.IsValid) { Random random = new Random(); Customer1 cx = new Customer1() { Id = random.Next(1000000000, 2000000000), Fname = customer.Fname, Lname = customer.Lname, Email = customer.Email, Phone = customer.Phone, UserPass = customer.UserPass }; _repo.CreateCustomer(cx); return(RedirectToAction("Index", "Home")); } else { return(View()); } } catch { return(View()); } }
// Insert methods protected void CreateUser_Click(object sender, EventArgs e) { var manager = Context.GetOwinContext().GetUserManager <ApplicationUserManager>(); var signInManager = Context.GetOwinContext().Get <ApplicationSignInManager>(); var user = new ApplicationUser() { UserName = tbEmail.Text, Email = tbEmail.Text }; IdentityResult result = manager.Create(user, "Password123"); //userMgr.AddToRole(user.Id,ddlrrole.SelectedValue); if (result.Succeeded) { string strnewUserId = user.Id; Customer1 NcbCustomer = new Customer1() { CustomerID = strnewUserId, Address = tbAddress.Text, FirstName = tbFname.Text, LastName = tbLName.Text }; AddUserToRole(tbEmail.Text, ddlrrole.SelectedValue); // Save additional fields to Customer Table BNS_webEntities1 customer = new BNS_webEntities1(); customer.Customer.Add(NcbCustomer); customer.SaveChanges(); Response.Redirect(Request.RawUrl); } else { // ErrorMessage.Text = result.Errors.FirstOrDefault(); } }
public void Maybe_As_WithValueReturnsCastValue() { Maybe <Customer1> a = new Customer1(); var b = a.As <CustomerBase>(); Assert.Equal <CustomerBase>(a.Value, b.Value); }
/** * Helper methods to set up the Given state */ private void givenARegisteredCustomer() { var register = RegisterCustomer.Build(emailAddress.Value, name.GivenName, name.FamilyName); customerID = register.CustomerId; confirmationHash = register.ConfirmationHash; registeredCustomer = Customer1.Register(register); }
static void Main(string[] args) { var customer = new Customer(); //var rating = customer.CalculaterRating(); var customer1 = new Customer1(); //Amazon.RateCalculator calculator = new RateCalculator(); }
public ActionResult DeleteConfirmed(int id) { Customer1 customer1 = db.Customers.Find(id); db.Customers.Remove(customer1); db.SaveChanges(); return(RedirectToAction("Index")); }
public CustomerViewModel() { _customer = new Customer1(); _customer.Name = "Customer Namedd"; _customer.LastName = "Last Name"; _customer.AppName = "Application NAme"; UpdateCommand = new RealyCommand(this); childViewModel = new CustomerInfoViewModel(); }
static void Main(string[] args) { Customer1 c1 = new Customer1(); DoSomething(c1); Customer2 c2 = new Customer2(); DoSomething(c2); }
public int UpdateCustomer(Customer1 cust) { using (db) { db.Entry(cust).State = System.Data.Entity.EntityState.Modified; db.SaveChanges(); return(1); } }
public ActionResult Edit([Bind(Include = "Customer1Id,name,address,email,username,pwd")] Customer1 customer1) { if (ModelState.IsValid) { db.Entry(customer1).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(customer1)); }
public IHttpActionResult GetCustomer(int id) { Customer1 customer = db.Customers.Find(id); if (customer == null) { return(NotFound()); } return(Ok(customer)); }
public int CreateCustomer(Customer1 cust) { using (db) { long id = db.Customers1.Max(x => x.CustomerId); cust.CustomerId = id + 1; db.Customers1.Add(cust); db.SaveChanges(); return(1); } }
public ActionResult Create([Bind(Include = "Customer1Id,name,address,email,username,pwd")] Customer1 customer1) { if (ModelState.IsValid) { db.Customers.Add(customer1); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(customer1)); }
public IActionResult AddCustomer(Customer1 obj) { int id = _db.Customer1s.Max(c => c.CustomerId); TempData["Cid"] = id + 1; _db.Customer1s.Add(obj); _db.SaveChanges(); return(View()); }
public static Domain.Models.Customer Map(Customer1 Cx) { return(new Domain.Models.Customer() { Id = Cx.Id, Fname = Cx.Fname, Lname = Cx.Lname, Email = Cx.Email, UserPass = Cx.UserPass, Phone = Cx.Phone }); }
public IHttpActionResult PostCustomer(Customer1 customer) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } db.Customers.Add(customer); db.SaveChanges(); return(CreatedAtRoute("DefaultApi", new { id = customer.CustomerId }, customer)); }
// GET: /Cust/Delete/5 public ActionResult Delete(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Customer1 customer1 = db.Customers.Find(id); if (customer1 == null) { return(HttpNotFound()); } return(View(customer1)); }
public IHttpActionResult DeleteCustomer(int id) { Customer1 customer = db.Customers.Find(id); if (customer == null) { return(NotFound()); } db.Customers.Remove(customer); db.SaveChanges(); return(Ok(customer)); }
protected void CreateUser_Click(object sender, EventArgs e) { var manager = Context.GetOwinContext().GetUserManager <ApplicationUserManager>(); var signInManager = Context.GetOwinContext().Get <ApplicationSignInManager>(); var user = new ApplicationUser() { UserName = Email.Text, Email = Email.Text }; IdentityResult result = manager.Create(user, Password.Text); if (result.Succeeded) { signInManager.SignIn(user, isPersistent: false, rememberBrowser: false); string strCurrentUserId = user.Id; Customer1 NcbCustomer = new Customer1() { CustomerID = strCurrentUserId, Address = tbAddress.Text, FirstName = tbFname.Text, LastName = tbLName.Text }; BNS_webEntities1 customer = new BNS_webEntities1(); customer.Customer.Add(NcbCustomer); try { customer.SaveChanges(); } catch (DbEntityValidationException x) { foreach (var eve in x.EntityValidationErrors) { Console.WriteLine("Entity of type \"{0}\" in state \"{1}\" has the following validation errors:", eve.Entry.Entity.GetType().Name, eve.Entry.State); foreach (var ve in eve.ValidationErrors) { Console.WriteLine("- Property: \"{0}\", Error: \"{1}\"", ve.PropertyName, ve.ErrorMessage); } } throw; } IdentityHelper.RedirectToReturnUrl(Request.QueryString["ReturnUrl"], Response); } else { ErrorMessage.Text = result.Errors.FirstOrDefault(); } }
public void useTestCustomer1() { var cust = new Customer1 { name = "Abhinaba Basu", address = "1835 73rd Ave NE, Medina, WA 98039", phone = new Phone { countryCode = 1, areaCode = 425, number = 9999999 } }; }
void registerCustomer() { // When registerCustomer var command = RegisterCustomer.Build(emailAddress.Value, name.GivenName, name.FamilyName); var customer = Customer1.Register(command); // Then it should succeed // and should have the expected state Assert.NotNull(customer); Assert.Equal(customer.CustomerId, command.CustomerId); Assert.Equal(customer.Name, command.Name); Assert.Equal(customer.EmailAddress, command.EmailAddress); Assert.Equal(customer.ConfirmationHash, command.ConfirmationHash); Assert.False(customer.IsEmailAddressConfirmed); }
public int DeleteCustomer(int id) { using (db) { var sp = from r in db.SoldProducts where (r.CustomerId == id) select r; foreach (var soldP in sp) { db.SoldProducts.Remove(soldP); } db.SaveChanges(); Customer1 cust = db.Customers1.Find(id); db.Customers1.Attach(cust); db.Customers1.Remove(cust); db.SaveChanges(); return(1); } }
public static ICustomer GetCustomerType(int customerTypeId) { ICustomer customer; if (customerTypeId == 1) { customer = new Customer1(); } else if (customerTypeId == 2) { customer = new Customer2(); } else { return(null); } return(customer); }
public void TestQueryable() { using (var db = new SQLiteDatabase(":memory:")) { db.SynchronizeSchema <Customer1>(); int max = 10; for (int i = 0; i < max; i++) { var customer = new Customer1(); customer.Id = i; customer.Name = "Name" + i; db.Save(customer, new SQLiteSaveOptions(db)); } var table = db.GetTable <Customer1>(); Assert.AreEqual(2, table.Columns.Count); Assert.AreEqual(nameof(SQLiteColumnType.INTEGER), table.GetColumn("Id").Type); Assert.AreEqual(nameof(SQLiteColumnType.TEXT), table.GetColumn("Name").Type); Assert.AreEqual(max, db.GetTableRows <Customer1>().Count()); var list = db.Query <Customer1>().Where(c => c.Name.StartsWith("name", StringComparison.OrdinalIgnoreCase)).Skip(2).Take(2).ToList(); Assert.AreEqual(2, list.Count); } }
public void UpdateBillingInfo() { Customer1 customerA = new Customer1(); homeURL = "http://automationpractice.com/index.php"; driver.Navigate().GoToUrl(homeURL); driver.FindElement(By.LinkText("Sign in")).Click(); driver.FindElement(By.Id("email")).Click(); driver.FindElement(By.Id("email")).Clear(); driver.FindElement(By.Id("email")).SendKeys("*****@*****.**"); driver.FindElement(By.Id("passwd")).Clear(); driver.FindElement(By.Id("passwd")).SendKeys("123456"); driver.FindElement(By.Id("SubmitLogin")).Click(); driver.FindElement(By.XPath("//span[contains(text(),'My addresses')]")).Click(); driver.FindElement(By.XPath("//span[contains(text(),'Add a new address')]")).Click(); //Firstname driver.FindElement(By.Id("firstname")).Click(); driver.FindElement(By.Id("firstname")).Clear(); driver.FindElement(By.Id("firstname")).SendKeys(customerA.getFirstName()); //Lastname driver.FindElement(By.Id("lastname")).Click(); driver.FindElement(By.Id("lastname")).Clear(); driver.FindElement(By.Id("lastname")).SendKeys(customerA.getLastName()); //Company driver.FindElement(By.Id("company")).Click(); driver.FindElement(By.Id("company")).Clear(); driver.FindElement(By.Id("company")).SendKeys(customerA.getCompany()); //Address driver.FindElement(By.Id("address1")).Click(); driver.FindElement(By.Id("address1")).Clear(); driver.FindElement(By.Id("address1")).SendKeys(customerA.getAddress()); //City driver.FindElement(By.Id("city")).Click(); driver.FindElement(By.Id("city")).Clear(); driver.FindElement(By.Id("city")).SendKeys(customerA.getCity()); //State IWebElement dropdown1 = driver.FindElement(By.Id("id_state")); SelectElement select1 = new SelectElement(dropdown1); select1.SelectByText(customerA.getState()); //PostalCode driver.FindElement(By.Id("postcode")).Click(); driver.FindElement(By.Id("postcode")).Clear(); driver.FindElement(By.Id("postcode")).SendKeys(customerA.getZip()); //Country IWebElement dropdown2 = driver.FindElement(By.Id("id_country")); SelectElement select2 = new SelectElement(dropdown2); select2.SelectByText("United States"); //Mobilephone driver.FindElement(By.Id("phone_mobile")).Click(); driver.FindElement(By.Id("phone_mobile")).Clear(); driver.FindElement(By.Id("phone_mobile")).SendKeys(customerA.getMobile()); //AdressAssignment driver.FindElement(By.Id("alias")).Click(); driver.FindElement(By.Id("alias")).Clear(); driver.FindElement(By.Id("alias")).SendKeys(customerA.getAssign()); //saving driver.FindElement(By.XPath("//span[contains(text(),'Save')]")).Click(); }
public void CreateAccountTest() { Customer1 customerA = new Customer1(); homeURL = "http://automationpractice.com/index.php"; driver.Navigate().GoToUrl(homeURL); driver.FindElement(By.XPath("//a[@class='login']")).Click(); driver.FindElement(By.XPath("//input[@id='email_create']")).Click(); driver.FindElement(By.XPath("//input[@id='email_create']")).SendKeys(customerA.getEmail()); driver.FindElement(By.XPath("//form[@id='create-account_form']//span[1]")).Click(); driver.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(3); driver.FindElement(By.XPath("//div[@class='clearfix']//div[1]//label[1]")).Click(); //firstname_customer driver.FindElement(By.Id("customer_firstname")).Click(); driver.FindElement(By.Id("customer_firstname")).Clear(); driver.FindElement(By.Id("customer_firstname")).SendKeys(customerA.getFirstName()); //Lastname_customer driver.FindElement(By.Id("customer_lastname")).Click(); driver.FindElement(By.Id("customer_lastname")).Clear(); driver.FindElement(By.Id("customer_lastname")).SendKeys(customerA.getLastName()); //password_customer driver.FindElement(By.Id("passwd")).Click(); driver.FindElement(By.Id("passwd")).Clear(); driver.FindElement(By.Id("passwd")).SendKeys(customerA.getCompany()); //DOB IWebElement dropdownday = driver.FindElement(By.Id("days")); SelectElement selectday = new SelectElement(dropdownday); selectday.SelectByIndex(1); //selectday.SelectByText(customerA.getDOB_day()); IWebElement dropdownmonth = driver.FindElement(By.Id("months")); SelectElement selectmonth = new SelectElement(dropdownmonth); selectmonth.SelectByIndex(3); //selectmonth.SelectByText(customerA.getDOB_month()); IWebElement dropdownyear = driver.FindElement(By.Id("years")); SelectElement selectyear = new SelectElement(dropdownyear); //selectyear.SelectByText(customerA.getDOB_year()); selectyear.SelectByIndex(1); //Firstname driver.FindElement(By.Id("firstname")).Click(); driver.FindElement(By.Id("firstname")).Clear(); driver.FindElement(By.Id("firstname")).SendKeys(customerA.getFirstName()); //Lastname driver.FindElement(By.Id("lastname")).Click(); driver.FindElement(By.Id("lastname")).Clear(); driver.FindElement(By.Id("lastname")).SendKeys(customerA.getLastName()); //Company driver.FindElement(By.Id("company")).Click(); driver.FindElement(By.Id("company")).Clear(); driver.FindElement(By.Id("company")).SendKeys(customerA.getCompany()); //Address driver.FindElement(By.Id("address1")).Click(); driver.FindElement(By.Id("address1")).Clear(); driver.FindElement(By.Id("address1")).SendKeys(customerA.getAddress()); //City driver.FindElement(By.Id("city")).Click(); driver.FindElement(By.Id("city")).Clear(); driver.FindElement(By.Id("city")).SendKeys(customerA.getCity()); //State IWebElement dropdown1 = driver.FindElement(By.Id("id_state")); SelectElement select1 = new SelectElement(dropdown1); select1.SelectByText(customerA.getState()); //PostalCode driver.FindElement(By.Id("postcode")).Click(); driver.FindElement(By.Id("postcode")).Clear(); driver.FindElement(By.Id("postcode")).SendKeys(customerA.getZip()); //Country IWebElement dropdown2 = driver.FindElement(By.Id("id_country")); SelectElement select2 = new SelectElement(dropdown2); select2.SelectByText("United States"); //Mobilephone driver.FindElement(By.Id("phone_mobile")).Click(); driver.FindElement(By.Id("phone_mobile")).Clear(); driver.FindElement(By.Id("phone_mobile")).SendKeys(customerA.getMobile()); //AdressAssignment driver.FindElement(By.Id("alias")).Click(); driver.FindElement(By.Id("alias")).SendKeys(customerA.getAssign()); //Register driver.FindElement(By.Name("submitAccount")).Click(); WebDriverWait wait = new WebDriverWait(driver, System.TimeSpan.FromSeconds(15)); Console.WriteLine("This line is working ------------"); Console.WriteLine("The name is " + customerA.getFirstName() + " " + customerA.getLastName()); //Console.WriteLine("The global driver is " + _myAccountPage.getRegisterName(globaldriver)); Assert.AreEqual((customerA.getFirstName() + " " + customerA.getLastName()), _myAccountPage.getAccountName(driver), "Account Name does not match"); driver.Quit(); }