public ActionResult updateSwapperPhoto(int idSwapper)
        {
            swapper user = service.Get(u => u.id_swapper == idSwapper);

            ViewBag.user = user;


            if (Request.Files[0].ContentLength > 0)
            {
                byte[] file = null;
                using (var binaryReader = new BinaryReader(Request.Files[0].InputStream))
                {
                    file = binaryReader.ReadBytes(Request.Files[0].ContentLength);
                }


                Image img = this.byteArrayToImage(file);
                img = new Bitmap(img, new Size(180, 180));

                string path = "~/swapperImgs/" + user.id_swapper + ".jpg";
                img.Save(Server.MapPath(path), System.Drawing.Imaging.ImageFormat.Jpeg);

                user.imgPath = path;
                service.Update(user);
                service.Commit();
            }

            return(RedirectToAction("toProfile", new { idSwapper = idSwapper }));
        }
        public ActionResult updateSwapper(int idSwapper)
        {
            swapper user = service.Get(u => u.id_swapper == idSwapper);

            ViewBag.user = user;

            string fName    = Request.Form["fName"];
            string lName    = Request.Form["lName"];
            string email    = Request.Form["email"];
            string adress   = Request.Form["adress"];
            string state    = Request.Form["state"];
            string phone    = Request.Form["phone"];
            string birthday = Request.Form["birthday"];

            int year  = int.Parse(birthday.Split('-')[0]);
            int month = int.Parse(birthday.Split('-')[1]);
            int day   = int.Parse(birthday.Split('-')[2]);

            user.firstname   = fName;
            user.lastname    = lName;
            user.email       = email;
            user.adress      = adress;
            user.state       = state;
            user.Phonenumber = long.Parse(phone);

            user.dateofbirth = new DateTime(year, month, day);


            return(RedirectToAction("toProfile", new { idSwapper = idSwapper }));
        }
        public ActionResult changeSwapperPassword(int idSwapper)
        {
            swapper user = service.Get(u => u.id_swapper == idSwapper);

            ViewBag.user = user;

            string passError = "";

            string currentPass = Request.Form["currentPass"];
            string newPass     = Request.Form["newPass"];
            string confirmPass = Request.Form["confirmPass"];


            if (user.password.Equals(currentPass))
            {
                user.password = newPass;

                service.Update(user);
                service.Commit();
            }
            else
            {
                passError = "Wrong password!";
            }


            return(RedirectToAction("toProfile2", new { idSwapper = idSwapper, passError = passError }));
        }
Exemplo n.º 4
0
 public void UpdateSwap(swapper other, float swap_completion)
 {
     if (swap_completion >= max_swap_completion)
     {
         max_swap_completion = swap_completion;
         UpdateSwapInternal(other, swap_completion);
     }
     swapless_time = 0;
 }
        public ActionResult renderAddGoods()
        {
            int connectedSwapper = 1; // identity connected user

            swapper user = swapperService.Get(u => u.id_swapper == connectedSwapper);

            ViewBag.user = user;

            IEnumerable <category> categories = categoryService.GetAll();

            category cat = categories.First();
            IEnumerable <subCategory> subCategories = subCategoryService.GetMany(s => s.categoryID == cat.id_category);

            ViewBag.categories    = categories;
            ViewBag.subCategories = subCategories;

            return(View());
        }
        public ActionResult toProfile2(int idSwapper, string passError)
        {
            swapper user = service.Get(u => u.id_swapper == idSwapper);

            ViewBag.user = user;
            if (user.imgPath.Equals("") && user.sex == Sex.M)
            {
                ViewBag.imgPath = "~/imgs/man.gif";
            }
            else if (user.imgPath.Equals("") && user.sex == Sex.F)
            {
                ViewBag.imgPath = "~/imgs/female.png";
            }
            else
            {
                ViewBag.imgPath = user.imgPath;
            }


            ViewBag.passError = passError;

            return(View("toProfile"));
        }
        public ActionResult toProfile(int idSwapper)
        {
            swapper user = service.Get(u => u.id_swapper == idSwapper);

            ViewBag.user = user;
            if (user.imgPath == null)
            {
                user.imgPath = "";
            }
            if (user.imgPath.Equals("") && user.sex == Sex.M)
            {
                ViewBag.imgPath = "~/imgs/man.gif";
            }
            else if (user.imgPath.Equals("") && user.sex == Sex.F)
            {
                ViewBag.imgPath = "~/imgs/female.png";
            }
            else
            {
                ViewBag.imgPath = user.imgPath;
            }

            return(View());
        }
        public swapper ConsultSwaper(int id)
        {
            swapper swp = ut.GetRepository <swapper>().Get(c => c.id_swapper == id);

            return(swp);
        }
        public ActionResult SaveMyGood(GoodModels GM)
        {
            System.Diagnostics.Debug.WriteLine("------------------------------------   :    " + GM.goood.id_goods);


            service = new GoodService();

            swapperService     = new SwapperService();
            categoryService    = new CategoryService();
            subCategoryService = new SubCategoryService();


            int connectedSwapper = 1;

            swapper user = swapperService.Get(u => u.id_swapper == connectedSwapper);

            ViewBag.user = user;


            string   brand       = Request.Form["brand"];
            string   description = Request.Form["desc"];
            DateTime date        = DateTime.Now;
            int      validity    = 0;
            int      quantity    = int.Parse(Request.Form["quantity"]);
            string   label       = Request.Form["label"];

            int idGood = int.Parse(Request.Form["idGood"]);

            Accpted accepted = Accpted.no;

            int catId = int.Parse(Request.Form["cat"]);
            //category cat = categoryService.Get(c => c.id_category == catId);

            int subCatId = int.Parse(Request.Form["subCat"]);

            //subCategory subCat = subCategoryService.Get(sc => sc.id_subCategory == subCatId);

            GM.goood             = service.GetById(idGood);
            GM.goood.label       = label;
            GM.goood.brand       = brand;
            GM.goood.description = description;
            GM.goood.date        = date;
            GM.goood.validity    = validity;
            GM.goood.quantity    = quantity;
            GM.goood.accepted    = accepted;

            //subCat.category = cat;

            GM.goood.subCategoryID = subCatId;
            GM.goood.swapperID     = user.id_swapper;

            service.Update(GM.goood);
            service.Commit();



            if (Request.Files[0].ContentLength > 0)
            {
                byte[] file = null;
                using (var binaryReader = new BinaryReader(Request.Files[0].InputStream))
                {
                    file = binaryReader.ReadBytes(Request.Files[0].ContentLength);
                }


                Image img = this.byteArrayToImage(file);
                img = new Bitmap(img, new Size(180, 180));

                string path = "~/swapperImgs/" + GM.goood.id_goods + ".jpg";
                img.Save(Server.MapPath(path), System.Drawing.Imaging.ImageFormat.Jpeg);

                GM.goood.image = path;
                service.Update(GM.goood);
                service.Commit();
            }

            return(RedirectToAction("SearchMyGood"));
        }
        public ActionResult addGoods()
        {
            service = new GoodService();

            swapperService     = new SwapperService();
            categoryService    = new CategoryService();
            subCategoryService = new SubCategoryService();


            int connectedSwapper = 1; // connected swapper -identity

            swapper user = swapperService.Get(u => u.id_swapper == connectedSwapper);

            ViewBag.user = user;


            string   brand       = Request.Form["brand"];
            string   description = Request.Form["desc"];
            DateTime date        = DateTime.Now;
            int      validity    = 0;
            int      quantity    = int.Parse(Request.Form["quantity"]);
            string   label       = Request.Form["label"];
            Accpted  accepted    = Accpted.no;

            int catId = int.Parse(Request.Form["cat"]);
            //category cat = categoryService.Get(c => c.id_category == catId);

            int subCatId = int.Parse(Request.Form["subCat"]);
            //subCategory subCat = subCategoryService.Get(sc => sc.id_subCategory == subCatId);

            goods newGood = new goods();

            newGood.label       = label;
            newGood.brand       = brand;
            newGood.description = description;
            newGood.date        = date;
            newGood.validity    = validity;
            newGood.quantity    = quantity;
            newGood.accepted    = accepted;

            //subCat.category = cat;

            newGood.subCategoryID = subCatId;
            newGood.swapperID     = user.id_swapper;
            service.Add(newGood);
            service.Commit();



            if (Request.Files[0].ContentLength > 0) // on a ajouté une image pour le produit
            {
                byte[] file = null;
                using (var binaryReader = new BinaryReader(Request.Files[0].InputStream))
                {
                    file = binaryReader.ReadBytes(Request.Files[0].ContentLength);
                }


                Image img = this.byteArrayToImage(file);
                img = new Bitmap(img, new Size(180, 180));

                string path = "~/swapperImgs/" + newGood.id_goods + ".jpg";
                img.Save(Server.MapPath(path), System.Drawing.Imaging.ImageFormat.Jpeg);


                newGood.image = path;
                service.Update(newGood);
                service.Commit();
            }



            return(RedirectToAction("SearchGood"));
        }
Exemplo n.º 11
0
 private void UpdateSwapInternal(swapper other, float swap_completion)
 {
 }