public async Task <UserOutfit> InsertUserOutfit(UserOutfit userOutfit) { using (var db = new DbConnection(m_connectionString)) { userOutfit.Id = await db.Connection.InsertAsync(userOutfit); return(userOutfit); } }
public static UserOutfit Instance() { if (_instance == null) { _instance = new UserOutfit(); } return(_instance); }
private void Start() { _meshRenderer = GetComponent <MeshRenderer>(); var outfit = UserOutfit.Instance().Outfit; if (outfit != null) { _meshRenderer.material = outfit; } }
private void SelectOutfit() { OutfitSelector[] selectors = FindObjectsOfType <OutfitSelector>(); foreach (var item in selectors) { item.Deselect(); } _isSelected = true; UserOutfit.Instance().SetOutfit(_outfit); StartCoroutine(RotateAnimation()); }
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 })); }
public async Task GetUserOutfits(int userId, int netId, bool startedCommerceSession) { List <UserOutfit> outfits = new List <UserOutfit>(); var player = Players[netId]; if (player == null) { return; } try { outfits = await m_database.GetUserOutfits(userId); var playerSrc = netId.ToString(); // No outfits so we need to add the default one if (outfits.Count == 0) { var defaultOutfit = Cache.Outfits.FirstOrDefault(o => o.Name == "Default (Grey)"); if (defaultOutfit != null) { await BuyItemForUser(userId, netId, defaultOutfit.Id, ShopItemType.OUTFIT, false); outfits = await m_database.GetUserOutfits(userId); } } if (startedCommerceSession) { List <UserOutfit> webshopOutfits = new List <UserOutfit>(); int deactivatedOutfits = 0; foreach (var outfit in Cache.Outfits) { if (outfit.TebexPackageId != 0) { bool existsInData = outfits.Exists(o => o.OutfitId == outfit.Id); bool owned = DoesPlayerOwnSkuExt(playerSrc, outfit.TebexPackageId); if (owned) { if (!existsInData) { var userOutfit = new UserOutfit { OutfitId = outfit.Id, UserId = userId, CreatedAt = DateTime.UtcNow }; userOutfit = await m_database.InsertUserOutfit(userOutfit); webshopOutfits.Add(userOutfit); } } else { if (existsInData) { var deletedItems = await m_database.DeleteUserOutfit(outfit.Id, userId); deactivatedOutfits += deletedItems; } } } } outfits.AddRange(webshopOutfits); if (player != null && (webshopOutfits.Count != 0 | deactivatedOutfits != 0)) { player.TriggerEvent("shop:webshopoutfits_count_update", webshopOutfits.Count, deactivatedOutfits); } } m_userOutfits.AddOrUpdate(netId, outfits, (key, oldValue) => oldValue = outfits); } catch (Exception ex) { m_logger.Exception("GetUserOutfits", ex); player.TriggerEvent("shop:webshop_error_loading"); } finally { m_userOutfits.TryGetValue(netId, out outfits); List <int> ownedOutfitIds = new List <int>(); foreach (var outfit in outfits) { ownedOutfitIds.Add(outfit.OutfitId); } player.TriggerEvent("shop:ownedoutfits", JsonConvert.SerializeObject(ownedOutfitIds)); } }