public void Post(Clothe value) { ClothesShopDBConnection DB = new ClothesShopDBConnection(); DB.Clothes.Add(value); DB.SaveChanges(); }
public void ClotheHasANameTest() { Clothe clothe = new Clothe(); clothe.Name = "Shirt"; Assert.AreEqual("Shirt", clothe.Name, "Clothe has a different name"); }
public void ClotheHasTypeTest() { Clothe clothe = new Clothe(); clothe.Type = "Large"; Assert.AreEqual("Large", clothe.Type, "Clothe has a different type"); }
public void ClotheIsSoldOfThisSexTest() { Clothe clothe = new Clothe(); clothe.Sex = "Male"; Assert.AreEqual("Male", clothe.Sex, "Clothe is for the opossite sex"); }
public void ClotheIsInThisSector() { Clothe clothe = new Clothe(); clothe.Delivered = true; Assert.AreEqual(true, clothe.Delivered, "Clothe is for a different sector"); }
public void ClothingIsSoldInThisCity() { Clothe clothe = new Clothe(); clothe.City = "Aytos"; Assert.AreEqual("Aytos", clothe.City, "Clothing is sold in a different city"); }
public void Delete(Clothe entity) { using (SqlCommand command = new SqlCommand("DELETE FROM Clothes WHERE ClotheId = @ClotheId")) { command.Parameters.AddWithValue("ClotheId", entity.ClotheId); DBMS.ExecuteNonQuery(command); } }
public void ClotheIdTest() { Clothe clothe = new Clothe(); clothe.Id = 1; Assert.AreEqual(1, clothe.Id, "Clothe Id is different"); }
public void ClotheQuantityTest() { Clothe clothe = new Clothe(); clothe.Quantity = 5; Assert.AreEqual(5, clothe.Quantity, "Clothe has a different quantity"); }
public void ClotheHasAPriceTest() { Clothe clothe = new Clothe(); clothe.Price = 29.99m; Assert.AreEqual(29.99m, clothe.Price, "Clothe has a different price"); }
public void Add(Clothe entity) { using (SqlCommand command = new SqlCommand("INSERT INTO Clothes (UnitPrice, Name) VALUES (@UnitPrice, @Name)")) { command.Parameters.AddWithValue("UnitPrice", entity.UnitPrice); command.Parameters.AddWithValue("Name", entity.Name); DBMS.ExecuteNonQuery(command); } }
public void Update(Clothe entity) { using (SqlCommand command = new SqlCommand("UPDATE Clothes SET Name = @Name, UnitPrice = @UnitPrice WHERE ClotheId = @ClotheId")) { command.Parameters.AddWithValue("ClotheId", entity.ClotheId); command.Parameters.AddWithValue("Name", entity.Name); command.Parameters.AddWithValue("UnitPrice", entity.UnitPrice); DBMS.ExecuteNonQuery(command); } }
public void Update(Clothe entity) { using (SqlCommand cmd = new SqlCommand("UPDATE Clothes set Name = @Name, UnitPrice=@UnitPrice WHERE ClotheId = @ClotheId")) { cmd.Parameters.AddWithValue("@ClotheId", entity.ClotheId); cmd.Parameters.AddWithValue("@Name", entity.Name); cmd.Parameters.AddWithValue("@UnitPrice", entity.UnitPrice); VTYS.SqlExecuteNonQuery(cmd); } }
public void Add(Clothe entity) { using (SqlCommand cmd = new SqlCommand("INSERT INTO Clothes (Name,UnitPrice) " + "VALUES(@Name,@UnitPrice)")) { cmd.Parameters.AddWithValue("Name", entity.Name); cmd.Parameters.AddWithValue("UnitPrice", entity.UnitPrice); VTYS.SqlExecuteNonQuery(cmd); } }
/// <summary> /// Add a product to the database /// </summary> public string Add(Clothe clothe) { using (clotheContext = new ClotheContext()) { clotheContext.Clothes.Add(clothe); clotheContext.SaveChanges(); } return("The element is added"); }
/// <summary> /// Update a single clothe in the database by Id. /// </summary> public void Update(Clothe clothe) { using (clotheContext = new ClotheContext()) { var item = clotheContext.Clothes.Find(clothe.Id); if (item != null) { clotheContext.Entry(item).CurrentValues.SetValues(clothe); clotheContext.SaveChanges(); } } }
[Route("api/Clothe")] // הוספת בגד חדש לdb public HttpResponseMessage Post([FromBody] Clothe newClothe) //(Clothe value) { var isSaved = DBQuery.AddNewClothe(newClothe); // the function return true if the clothe added to the db seccessfully' else return false. if (isSaved == true) { return(Request.CreateResponse(HttpStatusCode.OK, isSaved)); } else { return(Request.CreateResponse(HttpStatusCode.NotFound, "")); } }
//GET: Clothes/Details/5 public ActionResult Details(Guid?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Clothe clothe = db.Clothes.Find(id); if (clothe == null) { return(HttpNotFound()); } return(View(clothe)); }
public void ClotheCanBeAddedToDatabase() { Clothe clothe = new Clothe { Type = "Large", Name = "Shirt", Quantity = 5, Price = 29.99m, Sex = "Male", City = "Aytos", Delivered = true }; Assert.AreEqual("The element is added", clotheBusiness.Add(clothe), "Clothe can not be added to database"); }
private Clothe GetEditedProduct() { var clothe = new Clothe(); clothe.Id = editId; decimal price = 0; decimal.TryParse(txtPrice.Text, out price); clothe.Type = txtType.Text; clothe.Name = txtName.Text; clothe.Quantity = int.Parse(txtQuantity.Value.ToString()); clothe.Price = price; clothe.Sex = txtSex.Text; clothe.City = txtCity.Text; return(clothe); }
public List <Clothe> GetAll(Expression <Func <Clothe, bool> > filter = null) { var clotheList = new List <Clothe>(); SqlConnection connection = new SqlConnection(DBMS.Connection); SqlCommand command = new SqlCommand("SELECT * FROM Clothes", connection); command.Connection.Open(); var reader = command.ExecuteReader(); while (reader.Read()) { var clothe = new Clothe(); clothe.ClotheId = Convert.ToInt32(reader[0]); clothe.UnitPrice = Convert.ToDecimal(reader[1].ToString()); clothe.Name = reader[2].ToString(); clotheList.Add(clothe); } command.Connection.Close(); return(filter == null ? clotheList : clotheList.Where(filter.Compile()).ToList()); }
public List <Clothe> GetAll(Expression <Func <Clothe, bool> > filter = null) { List <Clothe> clotheList = new List <Clothe>(); SqlCommand cmd = new SqlCommand("Select * from Clothes"); SqlDataReader reader = VTYS.SqlExecuteReader(cmd); while (reader.Read()) { Clothe clothe = new Clothe { ClotheId = Convert.ToInt32(reader[0]), Name = reader[1].ToString(), UnitPrice = Convert.ToDecimal(reader[2]) }; clotheList.Add(clothe); } return(filter == null ? clotheList : clotheList.Where(filter.Compile()).ToList()); }
public ActionResult AddToCart(Guid?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Clothe clothe = db.Clothes.Find(id); if (clothe == null) { return(HttpNotFound()); } var shoppingCart = db.ShoppingCarts.OrderByDescending(x => x.DateCreated).Where(s => s.Paid == false).FirstOrDefault(); if (shoppingCart == null) { shoppingCart = db.ShoppingCarts.Add(new ShoppingCart()); } shoppingCart.AddToCart(clothe); db.SaveChanges(); //return RedirectToAction("Index", "ShoppingCarts"); return(RedirectToAction("Details", "ShoppingCart", new { id = shoppingCart.Id })); }
private void btnAdd_Click(object sender, EventArgs e) { var type = txtType; var name = txtName; var quantity = txtQuantity; var price = txtPrice; var sex = txtSex; var city = txtCity; const bool delivered = false; if (String.IsNullOrWhiteSpace(type.Text) || String.IsNullOrWhiteSpace(name.Text) || String.IsNullOrWhiteSpace(txtCity.Text) || !CityCheck(city.Text) || quantity.Value == 0 || decimal.Parse(price.Text) <= 0) { MessageBox.Show("One or more entries are empty", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { var clothe = new Clothe() { Type = type.Text, Name = name.Text, Quantity = int.Parse(quantity.Value.ToString().Split('.')[0]), Price = decimal.Parse(price.Text), Sex = sex.Text, City = city.Text, Delivered = delivered }; clotheBusiness.Add(clothe); } ClearBoxes(); UpdateGrid(); }
public Node(BinaryReader r) { Sprite = new Subresource <SpriteResource>(r); RagdollNode = r.ReadInt32(); ClotheType = (Clothe)r.ReadInt32(); }
public void Update(Clothe entity) { _clotheDal.Update(entity); }
public void Delete(Clothe entity) { _clotheDal.Delete(entity); }
public void Add(Clothe entity) { _clotheDal.Add(entity); }
public void addClothe(Clothe clothe) { shoped.Add(clothe); }
public void addClothe(Clothe clothe){ shoped.Add(clothe); }