Beispiel #1
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));
            }
        }
Beispiel #2
0
 // GET: Manufacturer
 public ActionResult Index()
 {
     using (GoodSupplyEntities db = new GoodSupplyEntities())
     {
         return(View(db.Manufacturers.ToList()));
     }
 }
Beispiel #3
0
 public ActionResult IndexClients()
 {
     using (GoodSupplyEntities db = new GoodSupplyEntities())
     {
         return(View(db.Clients.ToList()));
     }
 }
Beispiel #4
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());
            }
        }
        public ActionResult ShowItems(int?Id, string option = null, string search = null)
        {
            using (GoodSupplyEntities db = new GoodSupplyEntities())
            {
                List <ThumbnailProductsModel> Thumbnail = (from m in db.ManufacturerProducts
                                                           select new ThumbnailProductsModel
                {
                    ProductId = m.Id,
                    ProductName = m.Products.Name,
                    ManufacturerName = m.Manufacturers.Name,
                    CommerciallName = m.Name,
                    CatalogNumber = m.CatalogNumber,
                    ImageUrl = m.ImageUrl,
                    PackageQuantity = m.PackageQuantity,
                    Link = "/ProductDetail/Index/" + m.Id
                }).ToList();
                if (search != null)
                {
                    if (option == "ProductName" && search.Length > 0)
                    {
                        return(View(Thumbnail.Where(t => t.ProductName.ToLower().Contains(search.ToLower())).OrderBy(t => t.ProductName)));
                    }
                    if (option == "CatalogNumber" && search.Length > 0)
                    {
                        return(View(Thumbnail.Where(t => t.CatalogNumber.ToLower().Contains(search.ToLower())).OrderBy(t => t.ProductName)));
                    }

                    return(View(Thumbnail.Where(t => t.ProductName.ToLower().Contains(search.ToLower())).OrderBy(t => t.ProductName)));
                }

                return(View(Thumbnail.OrderBy(p => p.ProductName)));
            }
        }
Beispiel #6
0
        // GET: Client Delete
        public ActionResult ClientDelete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }

            using (GoodSupplyEntities db = new GoodSupplyEntities())
            {
                Clients client = db.Clients.Find(id);

                if (client == null)
                {
                    return(HttpNotFound());
                }

                ClientViewModel model = new ClientViewModel
                {
                    Id              = client.Id,
                    FirstName       = client.FirstName,
                    LastName        = client.LastName,
                    Email           = client.Email,
                    Phone           = client.Phone,
                    BusinessName    = client.BusinessName,
                    BusinessAddress = client.BusinessAddress,
                    VATIdNumber     = client.VATIdNumber
                };

                return(View(model));
            }
        }
Beispiel #7
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 MyProducts(int?Id, string option = null, string search = null)
        {
            //Add a view for supplier to see all his products in a list, with search button.
            using (GoodSupplyEntities db = new GoodSupplyEntities())
            {
                var myProducts = db.Prices.Include(p => p.ManufacturerProducts.Products).Include(p => p.ManufacturerProducts.Manufacturers).Include(p => p.Suppliers).Where(p => p.SupplierId == Id).ToList();

                //if (!String.IsNullOrEmpty(searchString))
                //{
                //    myProducts = myProducts.Where(s => s.ManufacturerProducts.Products.Name.Contains(searchString)
                //                           || s.FirstMidName.Contains(searchString));
                //}

                if (search != null)
                {
                    if (option == "ProductName" && search.Length > 0)
                    {
                        return(View(myProducts.Where(t => t.ManufacturerProducts.Products.Name.ToLower().Contains(search.ToLower())).OrderBy(t => t.ManufacturerProducts.Products.Name)));
                    }
                    if (option == "ManufacturerName" && search.Length > 0)
                    {
                        return(View(myProducts.Where(t => t.ManufacturerProducts.Manufacturers.Name.ToLower().Contains(search.ToLower())).OrderBy(t => t.ManufacturerProducts.Manufacturers.Name)));
                    }

                    return(View(myProducts.Where(t => t.ManufacturerProducts.Products.Name.ToLower().Contains(search.ToLower())).OrderBy(t => t.ManufacturerProducts.Products.Name)));
                }

                return(View(myProducts.OrderBy(p => p.ManufacturerProducts.Products.Name)));

                //return View(myProducts.ToList());
            }
        }
Beispiel #9
0
        // GET: Supplier Delete
        public ActionResult SupplierDelete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }

            using (GoodSupplyEntities db = new GoodSupplyEntities())
            {
                Suppliers supplier = db.Suppliers.Find(id);

                if (supplier == null)
                {
                    return(HttpNotFound());
                }

                SupplierViewModel model = new SupplierViewModel
                {
                    Id              = supplier.Id,
                    FirstName       = supplier.FirstName,
                    LastName        = supplier.LastName,
                    Email           = supplier.Email,
                    Phone           = supplier.Phone,
                    BusinessName    = supplier.BusinessName,
                    BusinessAddress = supplier.BusinessAddress,
                    VATIdNumber     = supplier.VATIdNumber
                };

                return(View(model));
            }
        }
        // GET: SupplierProducts/Edit/5
        public ActionResult Edit(int?id)
        {
            using (GoodSupplyEntities db = new GoodSupplyEntities())
            {
                if (id == null)
                {
                    return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
                }

                Prices prices = db.Prices.Find(id);

                if (prices == null)
                {
                    return(HttpNotFound());
                }

                var model = new PriceViewModel
                {
                    Prices = prices,
                    ManufacturerProducts = db.ManufacturerProducts.ToList(),
                    Suppliers            = db.Suppliers.ToList()
                };
                return(View(model));
            }
        }
        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));
            }
        }
        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));
            }
        }
Beispiel #13
0
        // GET: Details
        public ActionResult Details(int?id)
        {
            using (GoodSupplyEntities db = new GoodSupplyEntities())
            {
                if (id == null)
                {
                    return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
                }

                OrderDetails orderDetails = db.OrderDetails.Find(id);

                if (orderDetails == null)
                {
                    return(HttpNotFound());
                }

                var model = new OrderDetailViewModel
                {
                    OrderDetails         = orderDetails,
                    ManufacturerProducts = db.ManufacturerProducts.ToList(),
                    Orders = db.Orders.ToList()
                };
                return(View(model));
            }
        }
Beispiel #14
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));
            }
        }
Beispiel #15
0
        // GET: Delete
        public ActionResult Delete(int?id)
        {
            using (GoodSupplyEntities db = new GoodSupplyEntities())
            {
                if (id == null)
                {
                    return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
                }

                ManufacturerProducts manufacturerProducts = db.ManufacturerProducts.Find(id);

                if (manufacturerProducts == null)
                {
                    return(HttpNotFound());
                }

                var model = new ManufacturerProductViewModel
                {
                    ManufacturerProducts = manufacturerProducts,
                    Manufacturers        = db.Manufacturers.ToList(),
                    Products             = db.Products.ToList()
                };
                return(View(model));
            }
        }
 // GET: Category
 public ActionResult Index()
 {
     using (GoodSupplyEntities db = new GoodSupplyEntities())
     {
         var categories = db.Categories.Include(c => c.Parents);
         return(View(categories.ToList()));
     }
 }
Beispiel #17
0
 // GET: Product
 public ActionResult Index()
 {
     using (GoodSupplyEntities db = new GoodSupplyEntities())
     {
         var products = db.Products.Include(p => p.Categories);
         return(View(products.ToList()));
     }
 }
        // LOGIN PROPERTIES

        public ActionResult Index()
        {
            using (GoodSupplyEntities db = new GoodSupplyEntities())
            {
                var prices = db.Prices.Include(p => p.ManufacturerProducts).Include(p => p.Suppliers);
                return(View(prices.ToList()));
            }
        }
Beispiel #19
0
 // GET: ManufacturerProduct
 public ActionResult Index()
 {
     using (GoodSupplyEntities db = new GoodSupplyEntities())
     {
         var manufacturerProducts = db.ManufacturerProducts.Include(m => m.Manufacturers).Include(m => m.Products);
         return(View(manufacturerProducts.ToList()));
     }
 }
 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 }));
     }
 }
Beispiel #21
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"));
     }
 }
Beispiel #22
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 DeleteConfirmed(int id)
 {
     using (GoodSupplyEntities db = new GoodSupplyEntities())
     {
         Categories categories = db.Categories.Find(id);
         db.Categories.Remove(categories);
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
 }
Beispiel #24
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());
            }
        }
Beispiel #25
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"));
        }
Beispiel #26
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"));
        }
Beispiel #27
0
        public static IEnumerable <ThumbnailProductsModel> GetSupplierProductsThumbnails(this List <ThumbnailProductsModel> productsthumbnails, GoodSupplyEntities db = null, int id = 0, string option = null, string search = null)
        {
            try
            {
                if (db == null)
                {
                    db = new GoodSupplyEntities();
                }

                int supplierId = 0;
                if (id > 0)
                {
                    supplierId = id;
                }

                productsthumbnails = (from m in db.ManufacturerProducts
                                      join p in db.Prices on m.Id equals p.ManufacturerProductId
                                      where p.SupplierId.Equals(supplierId)
                                      select new ThumbnailProductsModel
                {
                    ProductId = m.Id,
                    ProductName = m.Products.Name,
                    ManufacturerName = m.Manufacturers.Name,
                    CommerciallName = m.Name,
                    CatalogNumber = m.CatalogNumber,
                    ImageUrl = m.ImageUrl,
                    PackageQuantity = m.PackageQuantity,
                    //Link = "/ProductDetail/Index/" + m.Id,
                    ProductPrice = p.ProductPrice
                }).ToList();                       // a list of thumbnails models

                //if (search != null)
                //    return thumbnails.Where(t => t.Name.ToLower().Contains(search.ToLower())).OrderBy(t => t.Name);

                if (search != null)
                {
                    if (option == "ProductName" && search.Length > 0)
                    {
                        return(productsthumbnails.Where(t => t.ProductName.ToLower().Contains(search.ToLower())).OrderBy(t => t.ProductName));
                    }
                    if (option == "CatalogNumber" && search.Length > 0)
                    {
                        return(productsthumbnails.Where(t => t.CatalogNumber.ToLower().Contains(search.ToLower())).OrderBy(t => t.ProductName));
                    }

                    return(productsthumbnails.Where(t => t.ProductName.ToLower().Contains(search.ToLower())).OrderBy(t => t.ProductName));
                }
            }
            catch (Exception ex)
            {
            }

            return(productsthumbnails.OrderBy(p => p.ProductName));
        }
        // GET: Details
        //public ActionResult Details(int? id)
        //{
        //    if (id == null)
        //    {
        //        return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
        //    }
        //    Categories categories = db.Categories.Find(id);
        //    if (categories == null)
        //    {
        //        return HttpNotFound();
        //    }
        //    return View(categories);
        //}


        // GET: Create
        public ActionResult Create()
        {
            using (GoodSupplyEntities db = new GoodSupplyEntities())
            {
                var categoriesList = db.Categories.ToList();
                var model          = new CategoryViewModel
                {
                    CategoriesList = categoriesList
                };
                return(View(model));
            }
        }
Beispiel #29
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));
     }
 }
Beispiel #30
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));
     }
 }