Exemple #1
0
        public void AffectNullProductToOffre(int idOffre, string ss)
        {
            product pr = new product();
            pr.offre_id = idOffre;
            pr.owner_username = ss;
            utOfWork.ProductRepository.Add(pr);
            utOfWork.Commit();

        }
        // GET: products/Create
        public ActionResult Create()
        {
            IOffreService offreService = new OffreService();
            ICategoryService CategoryService = new CategoryService();
          
            IEnumerable<offre> offres = offreService.GetOffres().ToList();
            offres = offres.Where(off => off.products.Count>0  &&  off.products.FirstOrDefault().owner_username.ToLower().Equals(((string)(Session["session"])).ToLower())).ToList();
            product product = new product { creationdate = DateTime.Now.Date };

            IEnumerable<category> categories = CategoryService.GetCategories().ToList();
            //categories = CategoryService.GetAllCategory().ToList();
            SelectList selectList = new SelectList(offres,"id", "name");
            product.owner_username = (string)(Session["session"]);
            SelectList selectList1 = new SelectList(categories, "id", "name");
            ViewData["offreList"] = selectList;
            ViewData["categoryList"] = selectList1;
                       return View(product);
        }
        public ActionResult Create(product p, HttpPostedFileBase file)
        {

            p.status = true;
                TempData["image"] = file;
                file = TempData["image"] as HttpPostedFileBase;
                if (file != null)
                {
                    photo photo = new photo();
                    var path = Path.Combine(Server.MapPath("~/Content/"), file.FileName);
                    file.SaveAs(path);
                    p.owner_username = (string)Session["session"];
                    photo.link = "~/Content/" + file.FileName;
                    photo.description = file.FileName;
                    productServicce.AddPhoto(photo);
                    p.photos_description = file.FileName;
                }
               
                productServicce.AddProduct(p);

         
            return RedirectToAction("Index");
        }
        public void UpdateProduct(product p)
        {

            utOfWork.ProductRepository.Update(p);
            utOfWork.Commit();

        }
 //l'ajout d'un produit
 public void AddProduct(product p)
 {
     utOfWork.ProductRepository.Add(p);
     utOfWork.Commit();
 }
        public ActionResult FollowsList()
        {
            IAdService service = null;
            service = new AdService();
            var user = new user();
            var user1 = new user();
            var user2 = new user();
            var user3 = new user();
            user.username = "******";
            user1.username = "******";
            user2.username = "******";
            user3.username = "******";
        var follower1 = new follower(user1, 10);
        var follower2 = new follower(user2, 5);
        var follower3 = new follower(user3, 7);

        //service.getAds();
         
          user.followers.Add(follower1);      
          user.followers.Add(follower2);
          user.followers.Add(follower3);
            offre offre1 = new offre();
            offre offre2 = new offre();
            offre offre3 = new offre();


            photo photo1 = new photo() ;
            
            photo photo2 = new photo();
            
            photo photo3 = new photo();
            

            offre1.description = "description offre 1 ";
            offre2.description = "description offre 2 description offre 2 description offre 2 description offre 2 description offre 2 ";
            offre3.description = "description offre 3 ";
            offre1.name = "offre1";
            offre2.name = "offre2";
            offre3.name = "offre3";

            product product1 = new product();
            product1.name = "test1";
            product1.description = "test1_discription";
            product1.offre = offre1;
            product1.photo = photo1;
            product1.photo.link = "~/Content/images/products/product01.png";
            product product2 = new product();
            //product1.photo.link.ToString();
            product2.name = "test2";
            product2.description = "test2_discription";
            product2.offre = offre2;
            product2.photo = photo2;
            product2.photo.link = "~/Content/images/products/product02.png";
            product product3 = new product();
            product3.name = "test3";
            product3.description = "test3_discription";
            product3.offre = offre3;
            product3.photo = photo3;
            product3.photo.link = "~/Content/images/products/product03.png";
            
            user1.products.Add(product1);
            user2.products.Add(product2);
            user3.products.Add(product3);
            //user.followers.Add(follower1);


            ViewBag.followers = new SelectList(user.followers, "FollowerId", "Rate");

            return View(user);

        }
        // GET: offre1
        public ActionResult Index(string id)
        {

            Home home = new Home();


         
            if (id !=null)
            {
                Session["peerid"] = id;}

            if (Session["session"] == null)
            {
                return RedirectToAction("Index", "User");
            }
        
                 ViewBag.EmployeeName = Session["peerid"];
                 ViewBag.Company = Session["session"];

           
          ViewBag.Company = Session["session"];
          home.offers = offreService.GetOffres().ToList();
        //Followers
          IAdService service = null;
          service = new AdService();
          var user = new user();
          var user1 = new user();
          var user2 = new user();
          var user3 = new user();
          user.username = "******";
          user1.username = "******";
          user2.username = "******";
          user3.username = "******";
          var follower1 = new follower(user1, 10);
          var follower2 = new follower(user2, 5);
          var follower3 = new follower(user3, 7);

          user.followers.Add(follower1);
          user.followers.Add(follower2);
          user.followers.Add(follower3);
          offre offre1 = new offre();
          offre offre2 = new offre();
          offre offre3 = new offre();


          photo photo1 = new photo();

          photo photo2 = new photo();

          photo photo3 = new photo();


          offre1.description = "description offre 1 ";
          offre2.description = "description offre 2 description offre 2 description offre 2 description offre 2 description offre 2 ";
          offre3.description = "description offre 3 ";
          offre1.name = "offre1";
          offre2.name = "offre2";
          offre3.name = "offre3";

          product product1 = new product();
          product1.name = "test1";
          product1.description = "test1_discription";
          product1.offre = offre1;
          product1.photo = photo1;
          product1.photo.link = "~/Content/images/products/product01.png";
          product product2 = new product();
          //product1.photo.link.ToString();
          product2.name = "test2";
          product2.description = "test2_discription";
          product2.offre = offre2;
          product2.photo = photo2;
          product2.photo.link = "~/Content/images/products/product02.png";
          product product3 = new product();
          product3.name = "test3";
          product3.description = "test3_discription";
          product3.offre = offre3;
          product3.photo = photo3;
          product3.photo.link = "~/Content/images/products/product03.png";

          user1.products.Add(product1);
          user2.products.Add(product2);
          user3.products.Add(product3);
          //user.followers.Add(follower1);

          IUser u1 = new UserService();
          user userc = u1.show(((string)Session["session"]).ToLower());
          IProductService prod = new ProductService();
         userc.products=prod.FindProductsByUser(((string)Session["session"]).ToLower()).ToList();

         IFollowerService f = new FollowerService();
           userc.followers= f.GetFollowers(userc.username).ToList();

          ViewBag.followers = new SelectList(userc.followers, "FollowerId", "Rate");

          home.user = user;

            return View(home);
        }