public ActionResult SaveUserOutfit(UserOutfitSelection userOutfitselection) { IList <Garment> garments = new List <Garment>(); ClosetOutfit co; for (int i = 0; i < userOutfitselection.ClosetOutfits.Length; i++) { garments.Add( closetRepository.GetClosetGarment(Convert.ToInt32(userOutfitselection.ClosetOutfits.GetValue(i))) .Garment); } try { co = outfitCreationService.CreateUserOutfit(this.UserId, garments, userOutfitselection.Season, userOutfitselection.PrivacyStatus); } catch (NotValidCombinationException) { return(Json(new { Success = false, Message = "Oops, looks like you have more than one of something in this outfit – please use only one jacket, one pant, etc. to create an outfit." })); } catch (CombinationAlreadyExistsException) { return(Json(new { Success = false, Message = "This combination already exists. Try again!" })); } new OutfitUpdaterServiceClient().MatchOutfitUpdatersForCloset(ClosetId); using (SearchEngineService ses = SearchEngineService.GetByCloset(ClosetId)) { ses.AddEntry(co.ToSearchEngineEntry()); } return(Json(new { Success = true })); }
public ActionResult SaveUserOutfit(UserOutfitSelection userOutfitselection) { UserOutfit uo = new UserOutfit(); uo.AddSeason(userOutfitselection.Season); MembershipUser mu = Membership.GetUser(); RegisteredUser user = registeredUserRepository.GetByMembershipId(Convert.ToInt32(mu.ProviderUserKey)); uo.User = user; for (int i = 0; i < userOutfitselection.ClosetOutfits.Length; i++) { uo.AddComponent(closetRepository.GetClosetGarment(Convert.ToInt32(userOutfitselection.ClosetOutfits.GetValue(i))).Garment); } uo.Visibility = userOutfitselection.PrivacyStatus; userOutfitRepository.SaveOrUpdate(uo); uo.Closet = user.Closet; closetOutfitRepository.SaveOrUpdate(uo); return(Json(new { Success = true })); }