public ActionResult RemoveGarmentFromCloset(int garmentSelected) { Closet closet = closetRepository.Get(this.ClosetId); ClosetGarment cg = new List <ClosetGarment>(closet.Garments).Find(e => e.Id.Equals(garmentSelected)); Garment g = cg.Garment; closet.RemoveGarment(cg); closetRepository.SaveOrUpdate(closet); closetRepository.RemoveGarmentFromCloset(closet.Id, g.Id); return(Json(new { Success = true })); }
private void UpdateOutfits(int closetId, IList <int> addedGarments) { processor.Closet = closetRepository.Get(closetId); processor.FashionFlavors.Clear(); foreach (UserFlavor uf in processor.Closet.User.UserFlavors) { processor.FashionFlavors.Add(uf.Flavor); } processor.Garments = garmentRepository.GetForProcess(closetId); processor.CreateCombinations(garmentRepository.GetByIds(addedGarments)); }
public ActionResult SetFavorite(OutfitRate outfitRate) { ClosetOutfit closetOutfit = closetOutfitRepository.Get(outfitRate.ClosetOutfitId); closetRepository.DbContext.BeginTransaction(); Closet c = closetRepository.Get(this.ClosetId); c.SetFavoriteOutfit(closetOutfit); closetRepository.SaveOrUpdate(c); closetRepository.DbContext.CommitTransaction(); string name = closetOutfitRepository.GetByClosetOutfitId(closetOutfit.Id).ShortEventTypes + closetOutfit.Id; return(Json(new { Success = true, SetFavorite = true, Name = name })); }
public JsonResult AddToCloset(WishListSelection wls) { closetRepository.DbContext.BeginTransaction(); // Remove from Wish List Garment g = new MasterGarment(wls.GarmentId); WishList wl = wishListRepository.GetForUser(this.ProxyLoggedUser); wl.RemoveWishGarment(new WishGarment(wls.WishListId)); // Add to closet Closet c = closetRepository.Get(this.ClosetId); c.AddGarment(g); closetRepository.DbContext.CommitTransaction(); List <int> ids = new List <int>(); ids.Add(wls.GarmentId); // Update the closet combinations (new FashionAde.Utils.OutfitEngineService.OutfitEngineServiceClient()).AddOutfits(this.ClosetId, ids); return(Json(new { Success = true })); }
public void CreateIndividualIndex(int closetId) { CreateIndex(_closetRepository.Get(closetId)); }
public ActionResult UploadFile(FormCollection values) { ArrayList lst = GetFormatedValues(values); RegisteredUser user = this.ProxyLoggedUser; IList <UserGarment> lstFiles = new List <UserGarment>(); List <int> garmentsIds = new List <int>(); userGarmentRepository.DbContext.BeginTransaction(); for (int i = 0; i < Request.Files.Count - 1; i++) { HttpPostedFileBase uploadedFile = Request.Files[i]; if (uploadedFile.ContentLength != 0) { UserGarment ug = (UserGarment)lst[i]; ug.User = user; ug.ImageUri = ""; ug.LinkUri = ""; // Find pregarment IDictionary <string, object> propertyValues = new Dictionary <string, object>(); propertyValues.Add("Silouhette", ug.Tags.Silouhette); propertyValues.Add("PatternType", ug.Tags.Pattern.Type); propertyValues.Add("ColorFamily", ug.Tags.DefaultColor.Family); ug.PreGarment = pregarmentRepository.FindOne(propertyValues); ug.UpdateSeasonCode(); ug.UpdateEventTypeCode(); userGarmentRepository.SaveOrUpdate(ug); FileInfo fi = new FileInfo(uploadedFile.FileName); string fileName = "user_" + ug.Id.ToString() + fi.Extension; string path = ConfigurationManager.AppSettings["Resources_Path"]; string filePath = Path.Combine(Path.Combine(path, @"Garments\UploadedImages\"), fileName); string smallImgPath = Path.Combine(Path.Combine(path, @"Garments\65\"), fileName); string largelImgPath = Path.Combine(Path.Combine(path, @"Garments\95\"), fileName); uploadedFile.SaveAs(filePath); // TODO: Improve borders. ImageHelper.MakeTransparent(filePath); ResizeImage(filePath, largelImgPath, 135, 95, true); //Imagenes Grandes ResizeImage(filePath, smallImgPath, 65, 65, true); //Imagenes Pequeñas ug.ImageUri = fileName; userGarmentRepository.SaveOrUpdate(ug); lstFiles.Add(ug); Closet closet = closetRepository.Get(this.ClosetId); closet.AddGarment(ug); closetRepository.SaveOrUpdate(closet); garmentsIds.Add(ug.Id); } } userGarmentRepository.DbContext.CommitTransaction(); new FashionAde.Utils.OutfitEngineService.OutfitEngineServiceClient().AddOutfits(user.Closet.Id, garmentsIds); ViewData["uploadedFiles"] = lstFiles; return(View()); }