Ejemplo n.º 1
0
        public int GetTargetRankingsByShard(Guid shardId, Guid characterId)
        {
            Bounty bounty = new Bounty();
            var topPlayers = new List<TopPlayers>();

            // Find all characters for the provided shardid
            IEnumerable<Character> characterList = this.db.Characters.Where(c => c.ShardId == shardId);

            // get placed on count for each character
            foreach (Character characterListItem in characterList)
            {
                topPlayers.Add(new TopPlayers
                {
                    CharacterId = characterListItem.Id,
                    count = bounty.GetBountiesPlacedOnCount(characterListItem.Id)
                });
            }

            // sort by killed count
            List<TopPlayers> sortedTopPlayers = topPlayers.OrderBy(c => c.count).ThenBy(c => c.CharacterId).Reverse().ToList();

            // find position in the list

            return (sortedTopPlayers.IndexOf(sortedTopPlayers.Where(c => c.CharacterId == characterId).Single()) + 1);
        }
Ejemplo n.º 2
0
        public int GetBountiesPlacedOnCount(Guid characterId)
        {
            Bounty bounty = new Bounty();

            return bounty.GetBountiesPlacedOnCount(characterId);
        }
Ejemplo n.º 3
0
        public string GetBountyStatus(Guid bountyId)
        {
            Bounty bounty = new Bounty();

            return bounty.GetStatus(bountyId);
        }
Ejemplo n.º 4
0
        public bool IsActiveBountyOnCharacter(Guid characterId)
        {
            Bounty bounty = new Bounty();

            return bounty.IsActiveBountyOnCharacter(characterId);
        }
Ejemplo n.º 5
0
 public void SetPendingPlacementToFalse(Bounty bounty)
 {
     bounty.IsPlacementPending = false;
     this.db.Entry(bounty).State = EntityState.Modified;
     this.db.SaveChanges();
 }
        public void SendBountyNotificationEmail(Bounty bounty, string emailType)
        {
            Account account = new Account();
            Favorite favorite = new Favorite();
            IQueryable<Favorite> favoritedCharacters;
            WatchedBounty watchedBounty = new WatchedBounty();
            IQueryable<WatchedBounty> watchedBounties;

            List<Guid> adminIds = new List<Guid>();
            IQueryable<Account> admins = account.GetAdminUserIds();

            foreach(Account admin in admins)
            {
                adminIds.Add(admin.Id);
            }

            switch(emailType)
            {
                case "Pending Placement":
                    // Admin Notification
                    foreach(Guid adminId in adminIds)
                    {
                        this.SendNotificationEmail(bounty, "PendingBountyPlaced-AdminAlert", adminId);
                    }

                    // Client Notification
                    this.SendNotificationEmail(bounty, "PendingBountyPlaced-ClientAlert", this.character.GetCharacterUserId(bounty.PlacedById));

                    break;

                case "Placement Approved":
                    // Client Notification
                    this.SendNotificationEmail(bounty, "BountyPlacedApproved-ClientAlert", this.character.GetCharacterUserId(bounty.PlacedById));

                    // Target Notification
                    this.SendNotificationEmail(bounty, "BountyPlacedApproved-TargetAlert", this.character.GetCharacterUserId(bounty.PlacedOnId));

                    // Favorited Notifications
                    favoritedCharacters = favorite.GetFavoritedCharacters(bounty.PlacedOnId);

                    foreach(Favorite favoritedCharacterItem in favoritedCharacters)
                    {
                        this.SendNotificationEmail(bounty, "BountyPlacedApproved-FavoritedAlert", favoritedCharacterItem.AccountId);
                    }

                    break;

                case "Pending Completion":
                    // Admin Notification
                    foreach(Guid adminId in adminIds)
                    {
                        this.SendNotificationEmail(bounty, "PendingBountyCompletion-AdminAlert", adminId);
                    }

                    // Hunter Notification
                    this.SendNotificationEmail(bounty, "PendingBountyCompletion-HunterAlert", this.character.GetCharacterUserId(bounty.KilledById.Value));

                    // Watcher Notifications
                    watchedBounties = watchedBounty.GetWatchedBounties(bounty.Id);

                    foreach(WatchedBounty watchedBountyItem in watchedBounties)
                    {
                        this.SendNotificationEmail(bounty, "PendingBountyCompletion-WatchedAccountAlert", watchedBountyItem.AccountId);
                    }

                    break;

                case "Completion Approved":
                    // Client Notification
                    this.SendNotificationEmail(bounty, "BountyCompletionApproved-ClientAlert", this.character.GetCharacterUserId(bounty.PlacedById));

                    // Hunter Notification
                    this.SendNotificationEmail(bounty, "BountyCompletionApproved-HunterAlert", this.character.GetCharacterUserId(bounty.KilledById.Value));

                    // Target Notification
                    this.SendNotificationEmail(bounty, "BountyCompletionApproved-TargetAlert", this.character.GetCharacterUserId(bounty.PlacedOnId));

                    // Watcher Notifications
                    watchedBounties = watchedBounty.GetWatchedBounties(bounty.Id);

                    foreach(WatchedBounty watchedBountyItem in watchedBounties)
                    {
                        this.SendNotificationEmail(bounty, "BountyCompletionApproved-WatchedAccountAlert", watchedBountyItem.AccountId);
                    }

                    // Favorited Notifications
                    favoritedCharacters = favorite.GetFavoritedCharacters(bounty.PlacedOnId);

                    foreach(Favorite favoritedCharacterItem in favoritedCharacters)
                    {
                        this.SendNotificationEmail(bounty, "BountyCompletionApproved-FavoritedAlert", favoritedCharacterItem.AccountId);
                    }

                    break;

                case "Placement Denied":
                    // Client Notification
                    this.SendNotificationEmail(bounty, "BountyPlacementDenied-ClientAlert", this.character.GetCharacterUserId(bounty.PlacedById));

                    break;

                case "Completion Denied":
                    // Hunter Notification
                    this.SendNotificationEmail(bounty, "BountyCompletionDenied-HunterAlert", this.character.GetCharacterUserId(bounty.KilledById.Value));

                    // Watcher Notifications
                    watchedBounties = watchedBounty.GetWatchedBounties(bounty.Id);

                    foreach(WatchedBounty watchedBountyItem in watchedBounties)
                    {
                        this.SendNotificationEmail(bounty, "BountyCompletionDenied-WatchedAccountAlert", watchedBountyItem.AccountId);
                    }

                    break;

                case "Bounty Cancelled":
                    // Admin Notification
                    foreach(Guid adminId in adminIds)
                    {
                        this.SendNotificationEmail(bounty, "BountyCancelled-AdminAlert", adminId);
                    }

                    // Target Notification
                    this.SendNotificationEmail(bounty, "BountyCancelled-TargetAlert", this.character.GetCharacterUserId(bounty.PlacedOnId));

                    // Watcher Notifications
                    watchedBounties = watchedBounty.GetWatchedBounties(bounty.Id);

                    foreach(WatchedBounty watchedBountyItem in watchedBounties)
                    {
                        this.SendNotificationEmail(bounty, "BountyCancelled-WatchedAccountAlert", watchedBountyItem.AccountId);
                    }

                    // Favorited Notifications
                    favoritedCharacters = favorite.GetFavoritedCharacters(bounty.PlacedOnId);

                    foreach(Favorite favoritedCharacterItem in favoritedCharacters)
                    {
                        this.SendNotificationEmail(bounty, "BountyCancelled-FavoritedAlert", favoritedCharacterItem.AccountId);
                    }

                    break;
            }
        }
Ejemplo n.º 7
0
        public ActionResult Edit(BountyCreateViewModel bountyCreateViewModel)
        {
            var loggedInUserId = this.bounty.GetLoggedInUserId();
            bountyCreateViewModel.Bounty = this.db.Bounties.Find(bountyCreateViewModel.Bounty.Id);
            bountyCreateViewModel.Character = this.db.Characters.Find(bountyCreateViewModel.Bounty.PlacedOnId);

            ModelState["Character.Name"].Errors.Clear();

            if(this.bounty.IsBountyOwner(loggedInUserId, bountyCreateViewModel.Bounty.Id) && this.bounty.GetStatus(bountyCreateViewModel.Bounty.Id) == "Placement Pending")
            {
                if(ModelState.IsValid)
                {
                    this.bounty = bountyCreateViewModel.Bounty;
                    this.db.Entry(this.bounty).State = EntityState.Modified;

                    this.bounty.PlacedOnId = bountyCreateViewModel.Bounty.PlacedOnId;
                    this.bounty.Amount = bountyCreateViewModel.Bounty.Amount;
                    this.bounty.Reason = bountyCreateViewModel.Bounty.Reason;
                    this.bounty.Message = bountyCreateViewModel.Bounty.Message;
                    this.bounty.PlacedById = bountyCreateViewModel.SelectedCharacter;

                    this.db.SaveChanges();
                    return RedirectToAction("Details", new { id = bountyCreateViewModel.Bounty.Id });
                }
                else
                {
                    var viewModel = new BountyCreateViewModel
                    {
                        Bounty = bountyCreateViewModel.Bounty,
                        Character = bountyCreateViewModel.Character,
                        SelectedCharacter = bountyCreateViewModel.Bounty.PlacedById
                    };

                    return View("Edit", viewModel);
                }
            }
            else
            {
                return RedirectToAction("Details", new { id = bountyCreateViewModel.Bounty.Id });
            }
        }
Ejemplo n.º 8
0
        public List<Bounty> GetAccountBountiesSignedUpFor(Guid accountId)
        {
            Bounty bounty = new Bounty();

            return bounty.GetAccountBountiesSignedUpFor(accountId);
        }
Ejemplo n.º 9
0
        public List<Bounty> GetAccountPendingBountiesPlaced(Guid accountId)
        {
            Bounty bounty = new Bounty();

            return bounty.GetAccountPendingBountiesPlaced(accountId);
        }
Ejemplo n.º 10
0
        public List<Bounty> GetAccountBountiesCompleted(Guid accountId)
        {
            Bounty bounty = new Bounty();

            return bounty.GetAccountBountiesCompleted(accountId);
        }
Ejemplo n.º 11
0
        public List<Bounty> GetAccountBountiesPlacedOn(Guid accountId)
        {
            Bounty bounty = new Bounty();

            return bounty.GetAccountBountiesPlacedOn(accountId);
        }
Ejemplo n.º 12
0
        public double GetAccountAmountSpent(Guid accountId)
        {
            Bounty bounty = new Bounty();

            return bounty.GetAccountAmountSpent(accountId);
        }
Ejemplo n.º 13
0
        public double GetAccountAmountEarned(Guid accountId)
        {
            Bounty bounty = new Bounty();

            return bounty.GetAccountAmountEarned(accountId);
        }
Ejemplo n.º 14
0
        public List<Bounty> GetAccountActiveBounties(Guid accountId)
        {
            Bounty bounty = new Bounty();

            return bounty.GetAccountActiveBounties(accountId);
        }
Ejemplo n.º 15
0
        public bool IsBountyWatched(Guid bountyId, Guid accountId)
        {
            Bounty bounty = new Bounty();

            return bounty.IsBountyWatched(bountyId, accountId);
        }
Ejemplo n.º 16
0
        public double GetAmountEarned(Guid characterId)
        {
            Bounty bounty = new Bounty();

            return bounty.GetAmountEarned(characterId);
        }
        public void SendNotificationEmail(Bounty bounty, string emailView, Guid accountId)
        {
            if(accountId != Guid.Empty)
            {
                if(this.db.Accounts.Find(accountId).EmailNotification == true)
                {
                    dynamic email = new Email(emailView);

                    string placedOn = bounty.CharacterName(bounty.PlacedOnId);
                    string placedBy = bounty.CharacterName(bounty.PlacedById);
                    string killedBy = string.Empty;
                    string shard = bounty.CharacterShard(bounty.PlacedOnId);

                    email.UserEmailAddress = this.db.Accounts.Find(accountId).EmailAddress;
                    email.Amount = bounty.Amount;
                    email.Reason = bounty.Reason;
                    email.Message = bounty.Message;
                    email.ClientName = placedBy;
                    email.TargetName = placedOn;
                    email.Shard = shard;
                    email.BountyId = bounty.Id;

                    if(bounty.KilledById != null)
                    {
                        killedBy = bounty.CharacterName(bounty.KilledById.Value);
                    }

                    try
                    {
                        email.Send();
                    }
                    catch
                    {
                        // Need to log when it fails, the email type and information
                    }
                }
            }
        }
Ejemplo n.º 18
0
        public double GetAmountWorth(Guid characterId)
        {
            Bounty bounty = new Bounty();

            return bounty.GetAmountWorth(characterId);
        }
Ejemplo n.º 19
0
        public void AddBountyNotificationMessage(Bounty bounty, string messageType)
        {
            Account account = new Account();
            Character character = new Character();
            Favorite favorite = new Favorite();
            IQueryable<Favorite> favoritedCharacters;
            WatchedBounty watchedBounty = new WatchedBounty();
            IQueryable<WatchedBounty> watchedBounties;

            Message adminMessage;
            Message clientMessage;
            Message hunterMessage;
            Message targetMessage;
            Message favoriteMessage;
            Message watcherMessage;

            List<Guid> adminIds = new List<Guid>();
            IQueryable<Account> admins = account.GetAdminUserIds();

            foreach(Account admin in admins)
            {
                adminIds.Add(admin.Id);
            }

            DateTime dateCreated = DateTime.Now;

            string placedOn = bounty.CharacterName(bounty.PlacedOnId);
            string placedBy = bounty.CharacterName(bounty.PlacedById);
            string killedBy = string.Empty;
            string shard = bounty.CharacterShard(bounty.PlacedOnId);

            if(bounty.KilledById != null)
            {
                killedBy = bounty.CharacterName(bounty.KilledById.Value);
            }

            string targetDescription;
            if(bounty.Reason == string.Empty || bounty.Reason == null)
            {
                targetDescription = string.Format("A bounty has been placed on your head by {0} - {1} in the amount of {2}.", placedBy, shard, bounty.Amount);
            }
            else
            {
                targetDescription = string.Format("A bounty has been placed on your head by {0} - {1} in the amount of {2} for '{3}'.", placedBy, shard, bounty.Amount, bounty.Reason);
            }

            switch(messageType)
            {
                case "Pending Placement":
                    // Admin Notification
                    foreach(Guid adminId in adminIds)
                    {
                        adminMessage = new Message
                        {
                            Id = Guid.NewGuid(),
                            UserId = adminId,
                            DateCreated = dateCreated,
                            Subject = string.Format("Placement submitted for approval on {0} - {1}", placedOn, shard),
                            Description = string.Format("A bounty has been placed by {0} - {1} on {2} - {3} in the amount of {4} that is pending your approval", placedBy, shard, placedOn, shard, bounty.Amount),
                            IsRead = false,
                            IsAdminMessage = true
                        };

                        db.Messages.Add(adminMessage);
                    }

                    // Client Notification
                    clientMessage = new Message
                    {
                        Id = Guid.NewGuid(),
                        UserId = character.GetCharacterUserId(bounty.PlacedById),
                        DateCreated = dateCreated,
                        Subject = string.Format("Bounty placement against {0} - {1} is Pending Approval", placedOn, shard),
                        Description = string.Format("We have recieved the bounty request against {0} - {1}. In order to finalize the bounty, you must deliver the bounty amount of {2} to one of our operatives. Once recieved, your bounty will be posted for every hunter in the galaxy to see in order to apprehend the target and bring them to whatever justice you so desired.", placedOn, shard, bounty.Amount),
                        IsRead = false,
                        IsAdminMessage = false
                    };

                    db.Messages.Add(clientMessage);

                    db.SaveChanges();

                    break;

                case "Placement Approved":
                    // Client Notification
                    clientMessage = new Message
                    {
                        Id = Guid.NewGuid(),
                        UserId = character.GetCharacterUserId(bounty.PlacedById),
                        DateCreated = dateCreated,
                        Subject = string.Format("Bounty placement against {0} - {1} has been Approved", placedOn, shard),
                        Description = string.Format("The bounty against {0} - {1} has been approved.  Every hunter in the galaxy will now be on the hunt. Once the target has been killed you will be alerted with photographic proof of the targets demise.", placedOn, bounty.Amount),
                        IsRead = false,
                        IsAdminMessage = false
                    };

                    db.Messages.Add(clientMessage);

                    // Target Notification
                    targetMessage = new Message
                    {
                        Id = Guid.NewGuid(),
                        UserId = character.GetCharacterUserId(bounty.PlacedOnId),
                        DateCreated = dateCreated,
                        Subject = string.Format("Bounty has been placed on {0} - {1}", placedOn, shard),
                        Description = targetDescription,
                        IsRead = false,
                        IsAdminMessage = false
                    };

                    db.Messages.Add(targetMessage);

                    // Favorited Notifications
                    favoritedCharacters = favorite.GetFavoritedCharacters(bounty.PlacedOnId);

                    foreach(Favorite favoritedCharacterItem in favoritedCharacters)
                    {
                        favoriteMessage = new Message
                        {
                            Id = Guid.NewGuid(),
                            UserId = favoritedCharacterItem.AccountId,
                            DateCreated = dateCreated,
                            Subject = string.Format("New bounty has been placed on {0} - {1}", placedOn, shard),
                            Description = string.Format("One of your favorited characters, {0} - {1}, has commited a crime against {2} - {3} and a bounty has been placed on their head.", placedOn, shard, placedBy, shard),
                            IsRead = false,
                            IsAdminMessage = false
                        };

                        db.Messages.Add(favoriteMessage);
                    }

                    db.SaveChanges();

                    break;

                case "Pending Completion":
                    // Admin Notification
                    foreach(Guid adminId in adminIds)
                    {
                        adminMessage = new Message
                        {
                            Id = Guid.NewGuid(),
                            UserId = adminId,
                            DateCreated = dateCreated,
                            Subject = string.Format("A bounty completion has been posted on {0} - {1} by {2} - {3}", placedOn, shard, killedBy, shard),
                            Description = string.Format("The bounty against {0} - {1} has been submitted for completion by {2} - {3}", placedOn, shard, killedBy, shard),
                            IsRead = false,
                            IsAdminMessage = true
                        };

                        db.Messages.Add(adminMessage);
                    }

                    // Hunter Notification
                    hunterMessage = new Message
                    {
                        Id = Guid.NewGuid(),
                        UserId = character.GetCharacterUserId(bounty.KilledById.Value),
                        DateCreated = dateCreated,
                        Subject = string.Format("The bounty being collected on {0} - {1} is pending approval for completion", placedOn, shard),
                        Description = string.Format("The bounty on {0} - {1} in the amount of {2} has been submitted for approval.  Once approved, the funds, minus any processing fees will be delivered to account.", placedOn, shard, bounty.Amount),
                        IsRead = false,
                        IsAdminMessage = false
                    };

                    db.Messages.Add(hunterMessage);

                    // Watcher Notifications
                    watchedBounties = watchedBounty.GetWatchedBounties(bounty.Id);

                    foreach(WatchedBounty watchedBountyItem in watchedBounties)
                    {
                        watcherMessage = new Message
                        {
                            Id = Guid.NewGuid(),
                            UserId = watchedBountyItem.AccountId,
                            DateCreated = dateCreated,
                            Subject = string.Format("The bounty being collected on {0} - {1} is pending approval for completion", placedOn, shard),
                            Description = string.Format("The bounty on {0} - {1} has been submitted for approval by another brave hunter. For the time being, please refrain from hunting the target. In the event that the collection request is denied, you will be alerted and thehunt can continue.", placedOn, shard),
                            IsRead = false,
                            IsAdminMessage = false
                        };

                        db.Messages.Add(watcherMessage);
                    }

                    db.SaveChanges();

                    break;

                case "Completion Approved":
                    // Client Notification
                    clientMessage = new Message
                    {
                        Id = Guid.NewGuid(),
                        UserId = character.GetCharacterUserId(bounty.PlacedById),
                        DateCreated = dateCreated,
                        Subject = string.Format("Bounty has been completed on {0} - {1}", placedOn, shard),
                        Description = string.Format("{0} - {1} has been killed by {2} - {3} and has successfully delivered your message, visual proof of the targets demise can be seen on the bounty details page.", placedOn, shard, killedBy, shard),
                        IsRead = false,
                        IsAdminMessage = false
                    };

                    db.Messages.Add(clientMessage);

                    // Hunter Notification
                    hunterMessage = new Message
                    {
                        Id = Guid.NewGuid(),
                        UserId = character.GetCharacterUserId(bounty.KilledById.Value),
                        DateCreated = dateCreated,
                        Subject = string.Format("Bounty has been completed on {0} - {1}", placedOn, shard),
                        Description = string.Format("The completion for the bounty on {0} - {1} in the amount of {2} has been approved. One of our representatives will be delivering the bounty amount minus any processing fees to you.  We congratulate you on your success and on an excellent hunt!", placedOn, shard, bounty.Amount),
                        IsRead = false,
                        IsAdminMessage = false
                    };

                    db.Messages.Add(hunterMessage);

                    // Target Notification
                    targetMessage = new Message
                    {
                        Id = Guid.NewGuid(),
                        UserId = character.GetCharacterUserId(bounty.PlacedOnId),
                        DateCreated = dateCreated,
                        Subject = string.Format("Bounty has been completed on {0} - {1}", placedOn, shard),
                        Description = string.Format("The bounty placed on your head has been completed by {0} - {1}.", killedBy, shard),
                        IsRead = false,
                        IsAdminMessage = false
                    };

                    db.Messages.Add(targetMessage);

                    // Watcher Notifications
                    watchedBounties = watchedBounty.GetWatchedBounties(bounty.Id);

                    foreach(WatchedBounty watchedBountyItem in watchedBounties)
                    {
                        watcherMessage = new Message
                        {
                            Id = Guid.NewGuid(),
                            UserId = watchedBountyItem.AccountId,
                            DateCreated = dateCreated,
                            Subject = string.Format("Bounty has been completed on {0} - {1}", placedOn, shard),
                            Description = string.Format("The bounty placed on {0} - {1} has been collected by {0} - {1}.  We ask that at this time you no longer continue the hunt. This bounty has been removed from all watch lists.", placedOn, shard, placedOn, shard, killedBy),
                            IsRead = false,
                            IsAdminMessage = false
                        };

                        db.Messages.Add(watcherMessage);
                    }

                    // Favorited Notifications
                    favoritedCharacters = favorite.GetFavoritedCharacters(bounty.PlacedOnId);

                    foreach(Favorite favoritedCharacterItem in favoritedCharacters)
                    {
                        favoriteMessage = new Message
                        {
                            Id = Guid.NewGuid(),
                            UserId = favoritedCharacterItem.AccountId,
                            DateCreated = dateCreated,
                            Subject = string.Format("Bounty has been completed on {0} - {1}", placedOn, shard),
                            Description = string.Format("The bounty on one of your favorited characters, {0} - {1} has been completed. {2} - {3} was the one who tracked and killed {4} - {5}.", placedOn, shard, killedBy, shard, placedOn, shard),
                            IsRead = false,
                            IsAdminMessage = false
                        };

                        db.Messages.Add(favoriteMessage);
                    }

                    db.SaveChanges();

                    break;

                case "Placement Denied":

                    // Client Notification
                    clientMessage = new Message
                    {
                        Id = Guid.NewGuid(),
                        UserId = character.GetCharacterUserId(bounty.PlacedById),
                        DateCreated = dateCreated,
                        Subject = string.Format("Bounty placed on {0} - {1} hase been denied", placedOn, shard),
                        Description = string.Format("The bounty placed on {0} - {1} in the amount of {2} has been denied.", placedOn, shard, bounty.Amount),
                        IsRead = false,
                        IsAdminMessage = false
                    };

                    db.Messages.Add(clientMessage);

                    db.SaveChanges();
                    break;

                case "Completion Denied":
                    // Hunter Notification
                    hunterMessage = new Message
                    {
                        Id = Guid.NewGuid(),
                        UserId = character.GetCharacterUserId(bounty.KilledById.Value),
                        DateCreated = dateCreated,
                        Subject = string.Format("The bounty on {0} - {1} that was submitted for completion has been denied.", placedOn, shard),
                        Description = string.Format("The bounty on {0} - {1} that was submitted for completion has been denied.", placedOn, shard),
                        IsRead = false,
                        IsAdminMessage = false
                    };

                    db.Messages.Add(hunterMessage);

                    // Watcher Notifications
                    watchedBounties = watchedBounty.GetWatchedBounties(bounty.Id);

                    foreach (WatchedBounty watchedBountyItem in watchedBounties)
                    {
                        watcherMessage = new Message
                        {
                            Id = Guid.NewGuid(),
                            UserId = watchedBountyItem.AccountId,
                            DateCreated = dateCreated,
                            Subject = string.Format("The bounty on {0} - {1} that was submitted for completion has been denied.", placedOn, shard),
                            Description = string.Format("The bounty on {0} - {1} that was submitted for completion has been denied. The target is still available to be hunted!", placedOn, shard),
                            IsRead = false,
                            IsAdminMessage = false
                        };

                        db.Messages.Add(watcherMessage);
                    }

                    db.SaveChanges();

                    break;

                case "Bounty Cancelled":
                    // Admin Notification
                    foreach (Guid adminId in adminIds)
                    {
                        adminMessage = new Message
                        {
                            Id = Guid.NewGuid(),
                            UserId = adminId,
                            DateCreated = dateCreated,
                            Subject = string.Format("The bounty placed on {0} - {1} has been cancelled by {1} - {1}", placedOn, shard, placedBy, shard),
                            Description = string.Format("The bounty placed on {0} - {1} has been cancelled by {1} - {1}", placedOn, shard, placedBy, shard),
                            IsRead = false,
                            IsAdminMessage = true
                        };

                        db.Messages.Add(adminMessage);
                    }

                    // Watcher Notifications
                    watchedBounties = watchedBounty.GetWatchedBounties(bounty.Id);

                    foreach (WatchedBounty watchedBountyItem in watchedBounties)
                    {
                        watcherMessage = new Message
                        {
                            Id = Guid.NewGuid(),
                            UserId = watchedBountyItem.AccountId,
                            DateCreated = dateCreated,
                            Subject = string.Format("The bounty on {0} - {1} has been cancelled by the client", placedOn, shard),
                            Description = string.Format("The bounty on {0} - {1} has been cancelled by the client. This bounty has been removed from your watch list", placedOn, shard),
                            IsRead = false,
                            IsAdminMessage = false
                        };

                        db.Messages.Add(watcherMessage);
                    }

                    // Favorited Notifications
                    favoritedCharacters = favorite.GetFavoritedCharacters(bounty.PlacedOnId);

                    foreach (Favorite favoritedCharacterItem in favoritedCharacters)
                    {
                        favoriteMessage = new Message
                        {
                            Id = Guid.NewGuid(),
                            UserId = favoritedCharacterItem.AccountId,
                            DateCreated = dateCreated,
                            Subject = string.Format("New bounty on {0} - {1} has been cancelled by the client", placedOn, shard),
                            Description = string.Format("The bounty on {0} - {1} has been cancelled by the client", placedOn, shard),
                            IsRead = false,
                            IsAdminMessage = false
                        };

                        db.Messages.Add(favoriteMessage);
                    }

                    // Target Notification
                    targetMessage = new Message
                    {
                        Id = Guid.NewGuid(),
                        UserId = character.GetCharacterUserId(bounty.PlacedOnId),
                        DateCreated = dateCreated,
                        Subject = string.Format("Bounty on {0} - {1} has been cancelled by the client", placedOn, shard),
                        Description = string.Format("The bounty placed on {0} - {1} has been cancelled by the client.", placedOn, shard),
                        IsRead = false,
                        IsAdminMessage = false
                    };

                    db.Messages.Add(targetMessage);

                    db.SaveChanges();

                    break;
            }
        }
Ejemplo n.º 20
0
        public List<Bounty> GetBountiesKilled(Guid characterId)
        {
            Bounty bounty = new Bounty();

            return bounty.GetBountiesCompleted(characterId);
        }
Ejemplo n.º 21
0
        public ActionResult UploadFiles(Bounty bounty)
        {
            var r = new List<KillShotImage>();

            foreach(string file in Request.Files)
            {
                HttpPostedFileBase hpf = Request.Files[file] as HttpPostedFileBase;
                string convertedFileName = DateTime.Now.ToString("MMddyyyyhhmmss");

                if(hpf.ContentLength == 0)
                {
                    continue;
                }

                string fileName = hpf.FileName;
                string filePath = @"Content\Images\";
                string convertedFilePath = @"Content\Images\KillShots";
                string thumbnailFilePath = @"Content\Images\Thumbnails\";

                this.killShotImage.Id = Guid.NewGuid();
                this.killShotImage.FileName = string.Concat(convertedFileName, ".jpg");
                this.killShotImage.FilePath = convertedFilePath;
                this.killShotImage.ThumbnailFileName = string.Concat(convertedFileName, "_thumbnail.jpg");
                this.killShotImage.FilePath = thumbnailFilePath;

                this.db.KillShotImages.Add(this.killShotImage);
                this.db.SaveChanges();

                bounty.KillShotImageId = this.killShotImage.Id;
                this.db.Entry(bounty).State = EntityState.Modified;
                this.db.SaveChanges();

                string savedFileName = Path.Combine(
                    AppDomain.CurrentDomain.BaseDirectory + filePath,
                    Path.GetFileName(fileName));

                hpf.SaveAs(savedFileName);

                // Create renamed original image
                string savedConvertedFileName = Path.Combine(
                    AppDomain.CurrentDomain.BaseDirectory + convertedFilePath,
                    Path.GetFileName(convertedFileName));

                Bitmap bitmap = new Bitmap(savedFileName);

                savedConvertedFileName = string.Concat(savedConvertedFileName, ".jpg");

                this.SaveJpegThumbnail(savedConvertedFileName, bitmap, 100);

                // Create thumbnail file and save
                string savedThumbnailFileName = Path.Combine(
                    AppDomain.CurrentDomain.BaseDirectory + thumbnailFilePath,
                    Path.GetFileName(convertedFileName));

                savedThumbnailFileName = string.Concat(savedThumbnailFileName, "_thumbnail.jpg");

                Image thumbnailKillShotImage = ResizeImage(bitmap, new Size(170, 170));

                this.SaveJpegThumbnail(savedThumbnailFileName, (Bitmap)thumbnailKillShotImage, 100);
            }

            return View();
        }
Ejemplo n.º 22
0
        public int GetBountiesKilledCount(Guid characterId)
        {
            Bounty bounty = new Bounty();

            return bounty.GetBountiesCompletedCount(characterId);
        }
Ejemplo n.º 23
0
        public Guid GetActiveBountyId(Guid characterId)
        {
            Bounty bounty = new Bounty();

            return bounty.GetActiveBountyId(characterId);
        }
Ejemplo n.º 24
0
 public void SetPendingCompletionToFalse(Bounty bounty)
 {
     bounty.IsCompletionPending = false;
     this.db.Entry(bounty).State = EntityState.Modified;
     this.db.SaveChanges();
 }