Ejemplo n.º 1
0
 public void Insert(Product product, string username)
 {
     product.Id       = GetNewId(ID_PREFIX_PRODUCT);
     product.View     = 0;
     product.Username = username;
     db.Products.Add(product);
     db.SaveChanges();
 }
Ejemplo n.º 2
0
        public string Insert(string recipient, string address, string phone)
        {
            Order order = new Order();

            order.Id           = GetNewId();
            order.CustomerName = recipient;
            order.Address      = address;
            order.PhoneNumber  = phone;
            order.CreatedDate  = DateTime.Now;
            order.Status       = 0;

            db.Orders.Add(order);
            db.SaveChanges();
            return(order.Id);
        }
Ejemplo n.º 3
0
 public ActionResult Edit([Bind(Include = "Id,CreatedDate,TotalCost,Status,CustomerId,CustomerName,Address,PhoneNumber")] Order order)
 {
     if (ModelState.IsValid)
     {
         db.Entry(order).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(order));
 }
Ejemplo n.º 4
0
        public static HeaderTransaction InsertHeaderTransaction(HeaderTransaction headerTransaction)
        {
            using (WatchShopEntities db = new WatchShopEntities())
            {
                db.HeaderTransaction.Add(headerTransaction);
                db.SaveChanges();

                return(headerTransaction);
            }
        }
Ejemplo n.º 5
0
        public static void DecreaseStock(int id, int quantity)
        {
            using (WatchShopEntities db = new WatchShopEntities())
            {
                Product product = db.Product.Where(x => x.id == id).FirstOrDefault();
                product.stock -= quantity;

                db.SaveChanges();
            }
        }
Ejemplo n.º 6
0
        public static DetailTransaction InsertDetailTransaction(DetailTransaction detailTransaction)
        {
            using (WatchShopEntities db = new WatchShopEntities())
            {
                db.DetailTransaction.Add(detailTransaction);
                db.SaveChanges();

                int productId = detailTransaction.product_id;
                int quantity  = detailTransaction.quantity.Value;
                ProductRepository.DecreaseStock(productId, quantity);

                return(detailTransaction);
            }
        }
Ejemplo n.º 7
0
        protected void DeleteButton_Click(object sender, EventArgs e)
        {
            Button currentButton    = (Button)sender;
            int    selectedRowIndex = 0;

            if (int.TryParse(currentButton.ID.Substring(0, currentButton.ID.Length - 2), out selectedRowIndex))
            {
                int productId = int.Parse(((Label)ProductTable.Rows[selectedRowIndex].Cells[6].Controls[0]).Text);

                using (WatchShopEntities db = new WatchShopEntities())
                {
                    Product toDeleteProduct = db.Product.Where(x => x.id == productId).First();
                    db.Product.Remove(toDeleteProduct);
                    db.SaveChanges();
                }

                Response.Redirect(Request.RawUrl);
            }
        }
Ejemplo n.º 8
0
 public void Insert(Branch branch)
 {
     branch.Id = GetNewId();
     db.Branches.Add(branch);
     db.SaveChanges();
 }
Ejemplo n.º 9
0
 public void Insert(User user)
 {
     db.Users.Add(user);
     db.SaveChanges();
 }
Ejemplo n.º 10
0
 public void Create(Role role)
 {
     db.Roles.Add(role);
     db.SaveChanges();
 }
Ejemplo n.º 11
0
 public void Insert(UserGroup userGroup)
 {
     userGroup.Id = GetNewId(ID_USER_GROUP_PREFIX);
     db.UserGroups.Add(userGroup);
     db.SaveChanges();
 }