예제 #1
0
        public void Post(Clothe value)
        {
            ClothesShopDBConnection DB = new ClothesShopDBConnection();

            DB.Clothes.Add(value);
            DB.SaveChanges();
        }
예제 #2
0
        public void ClotheHasANameTest()
        {
            Clothe clothe = new Clothe();

            clothe.Name = "Shirt";

            Assert.AreEqual("Shirt", clothe.Name, "Clothe has a different name");
        }
예제 #3
0
        public void ClotheHasTypeTest()
        {
            Clothe clothe = new Clothe();

            clothe.Type = "Large";

            Assert.AreEqual("Large", clothe.Type, "Clothe has a different type");
        }
예제 #4
0
        public void ClotheIsSoldOfThisSexTest()
        {
            Clothe clothe = new Clothe();

            clothe.Sex = "Male";

            Assert.AreEqual("Male", clothe.Sex, "Clothe is for the opossite sex");
        }
예제 #5
0
        public void ClotheIsInThisSector()
        {
            Clothe clothe = new Clothe();

            clothe.Delivered = true;

            Assert.AreEqual(true, clothe.Delivered, "Clothe is for a different sector");
        }
예제 #6
0
        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);
     }
 }
예제 #8
0
        public void ClotheIdTest()
        {
            Clothe clothe = new Clothe();

            clothe.Id = 1;

            Assert.AreEqual(1, clothe.Id, "Clothe Id is different");
        }
예제 #9
0
        public void ClotheQuantityTest()
        {
            Clothe clothe = new Clothe();

            clothe.Quantity = 5;

            Assert.AreEqual(5, clothe.Quantity, "Clothe has a different quantity");
        }
예제 #10
0
        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);
     }
 }
예제 #13
0
 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);
     }
 }
예제 #14
0
 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);
     }
 }
예제 #15
0
        /// <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");
        }
예제 #16
0
 /// <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();
         }
     }
 }
예제 #17
0
        [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, ""));
            }
        }
예제 #18
0
        //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");
        }
예제 #20
0
        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());
        }
예제 #22
0
        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());
        }
예제 #23
0
        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 }));
        }
예제 #24
0
        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();
        }
예제 #25
0
 public Node(BinaryReader r)
 {
     Sprite      = new Subresource <SpriteResource>(r);
     RagdollNode = r.ReadInt32();
     ClotheType  = (Clothe)r.ReadInt32();
 }
예제 #26
0
 public void Update(Clothe entity)
 {
     _clotheDal.Update(entity);
 }
예제 #27
0
 public void Delete(Clothe entity)
 {
     _clotheDal.Delete(entity);
 }
예제 #28
0
 public void Add(Clothe entity)
 {
     _clotheDal.Add(entity);
 }
예제 #29
0
 public void addClothe(Clothe clothe)
 {
     shoped.Add(clothe);
 }
예제 #30
0
 public void addClothe(Clothe clothe){
     shoped.Add(clothe);
 }