예제 #1
0
        public ActionResult Create(ManufacturerProductViewModel manufacturerProductVM)
        {
            using (GoodSupplyEntities db = new GoodSupplyEntities())
            {
                var manufacturerProducts = new ManufacturerProducts
                {
                    Name            = manufacturerProductVM.ManufacturerProducts.Name,
                    CatalogNumber   = manufacturerProductVM.ManufacturerProducts.CatalogNumber,
                    ImageUrl        = manufacturerProductVM.ManufacturerProducts.ImageUrl,
                    PackageQuantity = manufacturerProductVM.ManufacturerProducts.PackageQuantity,
                    Width           = manufacturerProductVM.ManufacturerProducts.Width,
                    Length          = manufacturerProductVM.ManufacturerProducts.Length,
                    Height          = manufacturerProductVM.ManufacturerProducts.Height,
                    Manufacturers   = manufacturerProductVM.ManufacturerProducts.Manufacturers,
                    ManufacturerId  = manufacturerProductVM.ManufacturerProducts.ManufacturerId,
                    Products        = manufacturerProductVM.ManufacturerProducts.Products,
                    ProductId       = manufacturerProductVM.ManufacturerProducts.ProductId
                };

                if (ModelState.IsValid)
                {
                    db.ManufacturerProducts.Add(manufacturerProducts);
                    db.SaveChanges();
                    return(RedirectToAction("Index"));
                }
                manufacturerProductVM.Manufacturers = db.Manufacturers.ToList();
                manufacturerProductVM.Products      = db.Products.ToList();
                return(View(manufacturerProductVM));
            }
        }
        public ActionResult Edit(PriceViewModel priceVM)
        {
            using (GoodSupplyEntities db = new GoodSupplyEntities())
            {
                var prices = new Prices
                {
                    Id = priceVM.Prices.Id,
                    ManufacturerPrice     = priceVM.Prices.ManufacturerPrice,
                    ProductPrice          = priceVM.Prices.ProductPrice,
                    Quantity              = priceVM.Prices.Quantity,
                    ManufacturerProductId = priceVM.Prices.ManufacturerProductId,
                    ManufacturerProducts  = priceVM.Prices.ManufacturerProducts,
                    SupplierId            = priceVM.Prices.SupplierId,
                    Suppliers             = priceVM.Prices.Suppliers
                };

                if (ModelState.IsValid)
                {
                    db.Entry(prices).State = EntityState.Modified;
                    db.SaveChanges();
                    return(RedirectToAction("Index"));
                }
                priceVM.ManufacturerProducts = db.ManufacturerProducts.ToList();
                priceVM.Suppliers            = db.Suppliers.ToList();
                return(View(priceVM));
            }
        }
예제 #3
0
        public ActionResult ClientChangePassword(ChangePasswordViewModel model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }
            else
            {
                using (GoodSupplyEntities db = new GoodSupplyEntities())
                {
                    var client = db.Clients.Where(c => c.Id == model.Id).FirstOrDefault();

                    if (client != null && client.Password == model.OldPassword)
                    {
                        client.Password = model.NewPassword;
                        db.SaveChanges();

                        Session["ChangePasswordSuccess"] = "הסיסמא שונתה בהצלחה.";
                        return(RedirectToAction("ClientLoggedIn", new { id = client.Id }));
                    }
                    else
                    {
                        ModelState.AddModelError("", "סיסמא אינה נכונה.");
                    }
                }
                return(View());
            }
        }
예제 #4
0
        public ActionResult SupplierChangePassword(ChangePasswordViewModel model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }
            else
            {
                using (GoodSupplyEntities db = new GoodSupplyEntities())
                {
                    var supplier = db.Suppliers.Where(s => s.Id == model.Id).FirstOrDefault();

                    if (supplier != null && supplier.Password == model.OldPassword)
                    {
                        supplier.Password = model.NewPassword;
                        db.SaveChanges();

                        Session["ChangePasswordSuccess"] = "הסיסמא שונתה בהצלחה.";
                        return(RedirectToAction("SupplierLoggedIn", new { id = supplier.Id }));
                    }
                    else
                    {
                        ModelState.AddModelError("", "סיסמא אינה נכונה.");
                    }
                }
                return(View());
            }
        }
        public ActionResult Create(PriceViewModel priceVM)
        {
            using (GoodSupplyEntities db = new GoodSupplyEntities())
            {
                var prices = new Prices
                {
                    ProductPrice          = priceVM.Prices.ProductPrice,
                    Quantity              = priceVM.Prices.Quantity,
                    ManufacturerPrice     = priceVM.Prices.ManufacturerPrice,
                    Suppliers             = priceVM.Prices.Suppliers,
                    SupplierId            = priceVM.Prices.SupplierId,
                    ManufacturerProducts  = priceVM.Prices.ManufacturerProducts,
                    ManufacturerProductId = priceVM.Prices.ManufacturerProductId
                };

                if (ModelState.IsValid)
                {
                    db.Prices.Add(prices);
                    db.SaveChanges();
                    return(RedirectToAction("Index"));
                }
                priceVM.Suppliers            = db.Suppliers.ToList();
                priceVM.ManufacturerProducts = db.ManufacturerProducts.ToList();
                return(View(priceVM));
            }
        }
예제 #6
0
        public ActionResult Create(OrderDetailViewModel orderDetailVM)
        {
            using (GoodSupplyEntities db = new GoodSupplyEntities())
            {
                var orderDetails = new OrderDetails
                {
                    Quantity              = orderDetailVM.OrderDetails.Quantity,
                    QuantityPrice         = orderDetailVM.OrderDetails.QuantityPrice,
                    ItemPrice             = orderDetailVM.OrderDetails.ItemPrice,
                    TotalOrderPrice       = orderDetailVM.OrderDetails.TotalOrderPrice,
                    OrderId               = orderDetailVM.OrderDetails.OrderId,
                    Orders                = orderDetailVM.OrderDetails.Orders,
                    ManufacturerProductId = orderDetailVM.OrderDetails.ManufacturerProductId,
                    ManufacturerProducts  = orderDetailVM.OrderDetails.ManufacturerProducts
                };

                if (ModelState.IsValid)
                {
                    db.OrderDetails.Add(orderDetails);
                    db.SaveChanges();
                    return(RedirectToAction("Index"));
                }
                orderDetailVM.ManufacturerProducts = db.ManufacturerProducts.ToList();
                orderDetailVM.Orders = db.Orders.ToList();
                return(View(orderDetailVM));
            }
        }
예제 #7
0
 public ActionResult DeleteConfirmed(int id)
 {
     using (GoodSupplyEntities db = new GoodSupplyEntities())
     {
         ManufacturerProducts manufacturerProducts = db.ManufacturerProducts.Find(id);
         db.ManufacturerProducts.Remove(manufacturerProducts);
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
 }
예제 #8
0
 public ActionResult DeleteConfirmed(int id)
 {
     using (GoodSupplyEntities db = new GoodSupplyEntities())
     {
         Categories categories = db.Categories.Find(id);
         db.Categories.Remove(categories);
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
 }
예제 #9
0
 public ActionResult DeleteConfirmed(int id)
 {
     using (GoodSupplyEntities db = new GoodSupplyEntities())
     {
         OrderDetails orderDetails = db.OrderDetails.Find(id);
         db.OrderDetails.Remove(orderDetails);
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
 }
 public ActionResult DeleteProductConfirmed(int id)
 {
     using (GoodSupplyEntities db = new GoodSupplyEntities())
     {
         Prices prices = db.Prices.Find(id);
         db.Prices.Remove(prices);
         db.SaveChanges();
         return(RedirectToAction("MyProducts", new { id = prices.SupplierId }));
     }
 }
예제 #11
0
        public ActionResult SupplierRegister(SupplierViewModel supplierVM)
        {
            SupplierViewModel model = new SupplierViewModel
            {
                //Id = supplierVM.Id,
                FirstName       = supplierVM.FirstName,
                LastName        = supplierVM.LastName,
                Email           = supplierVM.Email,
                Password        = supplierVM.Password,
                ConfirmPassword = supplierVM.ConfirmPassword,
                Phone           = supplierVM.Phone,
                BusinessName    = supplierVM.BusinessName,
                BusinessAddress = supplierVM.BusinessAddress,
                VATIdNumber     = supplierVM.VATIdNumber
            };

            if (!ModelState.IsValid)
            {
                return(View("SupplierRegister", model));
            }
            else
            {
                using (GoodSupplyEntities db = new GoodSupplyEntities())
                {
                    var user1 = db.Suppliers.Where(s => s.Email == model.Email).FirstOrDefault();
                    var user2 = db.Clients.Where(c => c.Email == model.Email).FirstOrDefault();

                    if (user1 != null || user2 != null)
                    {
                        ModelState.AddModelError("", "אימייל קיים כבר במערכת, נסה להרשם עם אימייל שונה.");
                        return(View("SupplierRegister", model));
                    }

                    var supplier = new Suppliers
                    {
                        //Id = supplierVM.Id,
                        FirstName       = supplierVM.FirstName,
                        LastName        = supplierVM.LastName,
                        Email           = supplierVM.Email,
                        Password        = supplierVM.Password,
                        Phone           = supplierVM.Phone,
                        BusinessName    = supplierVM.BusinessName,
                        BusinessAddress = supplierVM.BusinessAddress,
                        VATIdNumber     = supplierVM.VATIdNumber
                    };

                    db.Suppliers.Add(supplier);
                    db.SaveChanges();
                }
                ModelState.Clear();
                ViewBag.Message = supplierVM.FirstName + " " + supplierVM.LastName + " הצלחת להרשם בהצלחה.";

                return(View());
            }
        }
예제 #12
0
        public ActionResult ClientDeleteConfirmed(int id)
        {
            using (GoodSupplyEntities db = new GoodSupplyEntities())
            {
                Clients client = db.Clients.Find(id);
                db.Clients.Remove(client);
                db.SaveChanges();
            }

            return(RedirectToAction("Logout"));
        }
예제 #13
0
        public ActionResult SupplierDeleteConfirmed(int id)
        {
            using (GoodSupplyEntities db = new GoodSupplyEntities())
            {
                Suppliers supplier = db.Suppliers.Find(id);
                db.Suppliers.Remove(supplier);
                db.SaveChanges();
            }

            return(RedirectToAction("Logout"));
        }
예제 #14
0
 public ActionResult Edit(Manufacturers manufacturers)
 {
     using (GoodSupplyEntities db = new GoodSupplyEntities())
     {
         if (ModelState.IsValid)
         {
             db.Entry(manufacturers).State = EntityState.Modified;
             db.SaveChanges();
             return(RedirectToAction("Index"));
         }
         return(View(manufacturers));
     }
 }
예제 #15
0
 public ActionResult Create(Manufacturers manufacturers)
 {
     using (GoodSupplyEntities db = new GoodSupplyEntities())
     {
         if (ModelState.IsValid)
         {
             db.Manufacturers.Add(manufacturers);
             db.SaveChanges();
             return(RedirectToAction("Index"));
         }
         return(View(manufacturers));
     }
 }
예제 #16
0
        public ActionResult SupplierEdit(SupplierViewModel supplierVM)
        {
            var model = new SupplierViewModel
            {
                Id              = supplierVM.Id,
                FirstName       = supplierVM.FirstName,
                LastName        = supplierVM.LastName,
                Email           = supplierVM.Email,
                Phone           = supplierVM.Phone,
                BusinessName    = supplierVM.BusinessName,
                BusinessAddress = supplierVM.BusinessAddress,
                VATIdNumber     = supplierVM.VATIdNumber
            };

            if (!ModelState.IsValid)
            {
                return(View("SupplierEdit", model));
            }
            else
            {
                using (GoodSupplyEntities db = new GoodSupplyEntities())
                {
                    var supplierInDb = db.Suppliers.Single(s => s.Id == supplierVM.Id);

                    if (supplierInDb.Email != supplierVM.Email)
                    {
                        var user1 = db.Suppliers.Where(s => s.Email == model.Email).FirstOrDefault();
                        var user2 = db.Clients.Where(c => c.Email == model.Email).FirstOrDefault();

                        if (user1 != null || user2 != null)
                        {
                            ModelState.AddModelError("", "אימייל קיים כבר במערכת, נסה להרשם עם אימייל שונה.");
                            return(View("SupplierEdit", model));
                        }
                    }

                    supplierInDb.FirstName       = supplierVM.FirstName;
                    supplierInDb.LastName        = supplierVM.LastName;
                    supplierInDb.Email           = supplierVM.Email;
                    supplierInDb.Phone           = supplierVM.Phone;
                    supplierInDb.BusinessName    = supplierVM.BusinessName;
                    supplierInDb.BusinessAddress = supplierVM.BusinessAddress;
                    supplierInDb.VATIdNumber     = supplierVM.VATIdNumber;

                    db.SaveChanges();
                    return(RedirectToAction("SupplierLoggedIn", new { id = supplierVM.Id }));
                }
                //return RedirectToAction("Index", "Home");
            }
        }
예제 #17
0
        public ActionResult DeleteProduct(int Id)
        {
            using (GoodSupplyEntities db = new GoodSupplyEntities())
            {
                OrderDetails orderDetails = db.OrderDetails.Find(Id);

                var order   = db.Orders.Where(o => o.Id == orderDetails.OrderId).FirstOrDefault();
                var orderId = order.Id;
                if (order.ClientApproval == 0)
                {
                    db.OrderDetails.Remove(orderDetails);
                    db.SaveChanges();
                    return(RedirectToAction("OrderDetails", new { id = orderId }));
                }
                TempData["orderMessage"] = "לא ניתן למחוק מוצר זה, ההזמנה כבר אושרה על ידך";
                return(RedirectToAction("OrderDetails", new { id = orderId }));
            }
        }
예제 #18
0
        public ActionResult Edit(ProductViewModel productVM)
        {
            var products = new Products
            {
                Id         = productVM.Products.Id,
                Name       = productVM.Products.Name,
                Categories = productVM.Products.Categories,
                CategoryId = productVM.Products.CategoryId
            };

            using (GoodSupplyEntities db = new GoodSupplyEntities())
            {
                if (ModelState.IsValid)
                {
                    db.Entry(products).State = EntityState.Modified;
                    db.SaveChanges();
                    return(RedirectToAction("Index"));
                }
                productVM.Categories = db.Categories.ToList();
                return(View(productVM));
            }
        }
예제 #19
0
        public ActionResult Create(ProductViewModel productVM)
        {
            using (GoodSupplyEntities db = new GoodSupplyEntities())
            {
                var products = new Products
                {
                    Name       = productVM.Products.Name,
                    Categories = productVM.Products.Categories,
                    CategoryId = productVM.Products.CategoryId
                };

                if (ModelState.IsValid)
                {
                    db.Products.Add(products);
                    db.SaveChanges();
                    return(RedirectToAction("Index"));
                }

                productVM.Categories = db.Categories.ToList();
                return(View(productVM));
            }
        }
예제 #20
0
        public ActionResult Create(CategoryViewModel categoryVM)
        {
            using (GoodSupplyEntities db = new GoodSupplyEntities())
            {
                var categories = new Categories
                {
                    Name     = categoryVM.Categories.Name,
                    Parents  = categoryVM.Categories.Parents,
                    ParentId = categoryVM.Categories.ParentId
                };

                if (ModelState.IsValid)
                {
                    db.Categories.Add(categories);
                    db.SaveChanges();
                    return(RedirectToAction("Index"));
                }

                categoryVM.CategoriesList = db.Categories.ToList();
                return(View(categoryVM));
            }
        }
        public ActionResult SetSupplierProducts(SupplierSetProductsViewModel supplierSetProductsVM)
        {
            using (GoodSupplyEntities db = new GoodSupplyEntities())
            {
                var prices = new Prices
                {
                    ProductPrice          = supplierSetProductsVM.ProductPrice,
                    Quantity              = supplierSetProductsVM.Quantity,
                    ManufacturerPrice     = supplierSetProductsVM.ManufacturerPrice,
                    Suppliers             = db.Suppliers.FirstOrDefault(s => s.Id.Equals(supplierSetProductsVM.SupplierId)),
                    SupplierId            = supplierSetProductsVM.SupplierId,
                    ManufacturerProducts  = db.ManufacturerProducts.FirstOrDefault(m => m.Id.Equals(supplierSetProductsVM.ManufacturerProductId)),
                    ManufacturerProductId = supplierSetProductsVM.ManufacturerProductId
                };

                if (ModelState.IsValid)
                {
                    db.Prices.Add(prices);
                    db.SaveChanges();
                    return(RedirectToAction("ShowItems"));
                }
                return(View());
            }
        }
예제 #22
0
        public ActionResult Edit(CategoryViewModel categoryVM)
        {
            var categories = new Categories
            {
                Id       = categoryVM.Categories.Id,
                Name     = categoryVM.Categories.Name,
                Parents  = categoryVM.Categories.Parents,
                ParentId = categoryVM.Categories.ParentId
            };

            using (GoodSupplyEntities db = new GoodSupplyEntities())
            {
                //var categoryInDb = db.Categories.Single(c => c.Id == categoryVM.Categories.Id);

                if (ModelState.IsValid)
                {
                    db.Entry(categories).State = EntityState.Modified;
                    db.SaveChanges();
                    return(RedirectToAction("Index"));
                }
                categoryVM.CategoriesList = db.Categories.ToList();
                return(View(categoryVM));
            }
        }
예제 #23
0
        public ActionResult Create(OrderViewModel orderVM)
        {
            var orders = new Orders
            {
                CreateDate       = orderVM.Orders.CreateDate,
                PayDate          = orderVM.Orders.PayDate,
                Discount         = orderVM.Orders.Discount,
                TotalPrice       = orderVM.Orders.TotalPrice,
                ClientApproval   = orderVM.Orders.ClientApproval,
                SupplierApproval = orderVM.Orders.SupplierApproval,
                ClientId         = orderVM.Orders.ClientId,
                Clients          = orderVM.Orders.Clients,
                SupplierId       = orderVM.Orders.SupplierId,
                Suppliers        = orderVM.Orders.Suppliers
            };

            if (ModelState.IsValid)
            {
                db.Orders.Add(orders);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }
            orderVM.Suppliers = db.Suppliers.ToList();
            orderVM.Clients   = db.Clients.ToList();
            return(View(orderVM));
        }