public override int GetHashCode() { int hash = 1; if (TimestampMs != 0L) { hash ^= TimestampMs.GetHashCode(); } if (Sfida != false) { hash ^= Sfida.GetHashCode(); } if (actionCase_ == ActionOneofCase.CatchPokemon) { hash ^= CatchPokemon.GetHashCode(); } if (actionCase_ == ActionOneofCase.FortSearch) { hash ^= FortSearch.GetHashCode(); } if (actionCase_ == ActionOneofCase.BuddyPokemon) { hash ^= BuddyPokemon.GetHashCode(); } if (actionCase_ == ActionOneofCase.RaidRewards) { hash ^= RaidRewards.GetHashCode(); } if (actionCase_ == ActionOneofCase.PasscodeRewards) { hash ^= PasscodeRewards.GetHashCode(); } if (actionCase_ == ActionOneofCase.CompleteQuest) { hash ^= CompleteQuest.GetHashCode(); } if (actionCase_ == ActionOneofCase.CompleteQuestStampCard) { hash ^= CompleteQuestStampCard.GetHashCode(); } if (actionCase_ == ActionOneofCase.CompleteQuestPokemonEncounter) { hash ^= CompleteQuestPokemonEncounter.GetHashCode(); } if (actionCase_ == ActionOneofCase.OpenGift) { hash ^= OpenGift.GetHashCode(); } if (actionCase_ == ActionOneofCase.SendGift) { hash ^= SendGift.GetHashCode(); } if (actionCase_ == ActionOneofCase.Trading) { hash ^= Trading.GetHashCode(); } hash ^= (int)actionCase_; if (_unknownFields != null) { hash ^= _unknownFields.GetHashCode(); } return(hash); }
public void MergeFrom(ActionLogEntry other) { if (other == null) { return; } if (other.TimestampMs != 0L) { TimestampMs = other.TimestampMs; } if (other.Sfida != false) { Sfida = other.Sfida; } switch (other.ActionCase) { case ActionOneofCase.CatchPokemon: if (CatchPokemon == null) { CatchPokemon = new global::POGOProtos.Data.Logs.CatchPokemonLogEntry(); } CatchPokemon.MergeFrom(other.CatchPokemon); break; case ActionOneofCase.FortSearch: if (FortSearch == null) { FortSearch = new global::POGOProtos.Data.Logs.FortSearchLogEntry(); } FortSearch.MergeFrom(other.FortSearch); break; case ActionOneofCase.BuddyPokemon: if (BuddyPokemon == null) { BuddyPokemon = new global::POGOProtos.Data.Logs.BuddyPokemonLogEntry(); } BuddyPokemon.MergeFrom(other.BuddyPokemon); break; case ActionOneofCase.RaidRewards: if (RaidRewards == null) { RaidRewards = new global::POGOProtos.Data.Logs.RaidRewardsLogEntry(); } RaidRewards.MergeFrom(other.RaidRewards); break; case ActionOneofCase.PasscodeRewards: if (PasscodeRewards == null) { PasscodeRewards = new global::POGOProtos.Data.Logs.PasscodeRewardsLogEntry(); } PasscodeRewards.MergeFrom(other.PasscodeRewards); break; case ActionOneofCase.CompleteQuest: if (CompleteQuest == null) { CompleteQuest = new global::POGOProtos.Data.Logs.CompleteQuestLogEntry(); } CompleteQuest.MergeFrom(other.CompleteQuest); break; case ActionOneofCase.CompleteQuestStampCard: if (CompleteQuestStampCard == null) { CompleteQuestStampCard = new global::POGOProtos.Data.Logs.CompleteQuestStampCardLogEntry(); } CompleteQuestStampCard.MergeFrom(other.CompleteQuestStampCard); break; case ActionOneofCase.CompleteQuestPokemonEncounter: if (CompleteQuestPokemonEncounter == null) { CompleteQuestPokemonEncounter = new global::POGOProtos.Data.Logs.CompleteQuestPokemonEncounterLogEntry(); } CompleteQuestPokemonEncounter.MergeFrom(other.CompleteQuestPokemonEncounter); break; case ActionOneofCase.OpenGift: if (OpenGift == null) { OpenGift = new global::POGOProtos.Data.Logs.OpenGiftLogEntry(); } OpenGift.MergeFrom(other.OpenGift); break; case ActionOneofCase.SendGift: if (SendGift == null) { SendGift = new global::POGOProtos.Data.Logs.SendGiftLogEntry(); } SendGift.MergeFrom(other.SendGift); break; case ActionOneofCase.Trading: if (Trading == null) { Trading = new global::POGOProtos.Data.Logs.TradingLogEntry(); } Trading.MergeFrom(other.Trading); break; } _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields); }
public ActionResult SendGift(SendGift sendGift) { if (!ModelState.IsValid) { return(View(sendGift)); } Game gameExists = _session.Query <Game>() .Where(g => g.Title == sendGift.GameTitle) .SingleOrDefault(); if (gameExists == null) { ModelState.AddModelError("GameTitle", "No game with that title exists."); return(View()); } User userExists = _session.Query <User>() .Where(u => u.Username == sendGift.ReceiverName) .SingleOrDefault(); if (userExists == null) { ModelState.AddModelError("ReceiverName", "No user with that name exists."); return(View()); } User sender = _session.Get <User>(_context.UserId); if (sender.Wallet < gameExists.Price) { ModelState.AddModelError(string.Empty, "Insufficient funds to purchase game"); return(View()); } if (userExists.GiftsOwned == null) { userExists.GiftsOwned = Enumerable.Empty <Gift>(); } Gift giftExists = userExists.GiftsOwned.FirstOrDefault(g => g.GameId == gameExists.Id); if (userExists.GamesOwned.Contains <Game>(gameExists) || (giftExists != null && !giftExists.Returned)) { ModelState.AddModelError(string.Empty, "The user already owns or has been gifted this game"); return(View()); } Gift gift = new Gift { ReceiverId = userExists.Id, SenderId = sender.Id, GameId = gameExists.Id, Returned = false, Message = sendGift.Message }; List <Gift> giftList = new List <Gift> { gift }; using (var txn = _session.BeginTransaction()) { _session.SaveOrUpdate(gift); txn.Commit(); } using (var txn = _session.BeginTransaction()) { userExists.GiftsOwned = userExists.GiftsOwned.Concat(giftList); sender.Wallet = sender.Wallet - gameExists.Price; _session.SaveOrUpdate(userExists); _session.SaveOrUpdate(sender); txn.Commit(); } ModelState.AddModelError(string.Empty, "Gift successfully sent!"); return(View(sendGift)); }