public ActionResult SearchGood(GoodModels SwapMod) { if (SwapMod.txt == null) { SwapMod.txt = ""; } category bestCategory = service.mostRatedCategory(); System.Diagnostics.Debug.WriteLine("-- MRC =" + bestCategory.name); ViewBag.bestCat = bestCategory.name; if (SwapMod.txt.Equals("")) { SwapMod.listGoods = service.GetAll(); SwapMod.txtSearch = ""; return(View("SearchGood", SwapMod)); } SwapMod.listGoods = service.GetMany(c => c.label.Contains(SwapMod.txt)); SwapMod.txtSearch = ""; return(View("SearchGood", SwapMod)); }
public ActionResult SearchMyGood2(GoodModels SwapMod) { int idSwapper = 1; //utilisateur connecté ViewBag.deleted = true; if (SwapMod.txt == null) { SwapMod.txt = ""; } System.Diagnostics.Debug.WriteLine("------------------------------------ : STR =" + SwapMod.txt); if (SwapMod.txt.Equals("")) { SwapMod.listGoods = service.GetMany(c => c.swapperID == idSwapper); SwapMod.txtSearch = ""; // System.Diagnostics.Debug.WriteLine("------------------------------------ : Vide !!"); return(View("SearchMyGood", SwapMod)); } SwapMod.listGoods = service.GetMany(c => c.label.Contains(SwapMod.txt) & c.swapperID == idSwapper); //System.Diagnostics.Debug.WriteLine("------------------------------------ : Done !!"); SwapMod.txtSearch = ""; return(View("SearchMyGood", SwapMod)); }
public ActionResult SearchGoodSort(GoodModels SwapMod) { SwapMod.listGoods = service.searchByScore(); SwapMod.txtSearch = ""; System.Diagnostics.Debug.WriteLine("------------------------------------ : Vide !!"); return(View("SearchGood", SwapMod)); }
public ActionResult DeleteMyGood(int id) { GoodModels GM = new GoodModels(); GM.goood = service.GetById(id); service.Delete(GM.goood); service.Commit(); return(RedirectToAction("SearchMyGood2")); }
public ActionResult UpdateMyGood(int id) { GoodModels GM = new GoodModels(); GM.goood = service.GetById(id); List <category> categories = new List <category>(); categories.Add(GM.goood.subCategory.category); categories.AddRange(categoryService.GetMany(c => c.id_category != GM.goood.subCategory.categoryID)); IEnumerable <subCategory> subCategories = subCategoryService.GetMany(s => s.categoryID == GM.goood.subCategory.category.id_category); ViewBag.categories = categories; ViewBag.subCategories = subCategories; return(View(GM)); }
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")); }