public ActionResult Details(Guid id, BountyDetailModel bountyDetailModel) { Bounty bounty = this.db.Bounties.Find(id); Guid loggedInUser = Guid.Empty; IQueryable<Character> characters; IQueryable<Character> defaultCharacter; // Need to check to ensure the bounty is still active // if completed // ModelState.AddModelError(string.Empty, "The bounty for this target has already been submitted."); // else if pending completion // ModelState.AddModelError(string.Empty, "The bounty for this target has been submitted for approval."); foreach(string file in Request.Files) { HttpPostedFileBase hpf = Request.Files[file] as HttpPostedFileBase; if(hpf.FileName == null || hpf.FileName == string.Empty) { ModelState.AddModelError(string.Empty, "You must first upload a file to complete the bounty."); } if(hpf.ContentType != "image/jpeg") { if(hpf.ContentType != "image/png") { if(hpf.ContentType != "image/bmp") { if(hpf.ContentType != "image/gif") { if(hpf.ContentType != "image/tiff") { ModelState.AddModelError(string.Empty, "Only images can be uploaded."); } } } } } } ModelState["KillShotImageId"].Errors.Clear(); if(ModelState.IsValid) { if(Request.IsAuthenticated) { loggedInUser = this.account.GetLoggedInUserId(); characters = this.character.GetAllCharactersOnAShardForAnAccount(loggedInUser, bounty.CharacterShard(bounty.PlacedOnId)); defaultCharacter = this.character.GetDefaultCharacterForAnAccount(loggedInUser); if(defaultCharacter.Count() != 0) { if(defaultCharacter.Single().Shard.Name == bounty.CharacterShard(bounty.PlacedOnId)) { ViewBag.CharacterList = new SelectList(characters, "Id", "Name", defaultCharacter.Single().Id); } else { ViewBag.CharacterList = new SelectList(characters, "Id", "Name"); } } } bounty.KilledById = bountyDetailModel.SelectedCharacter; bounty.IsCompletionPending = true; bounty.DateCompleted = DateTime.Now; this.db.Entry(bounty).State = EntityState.Modified; this.db.SaveChanges(); this.UploadFiles(bounty); // Send email notification this.emailNotificationHelper.SendBountyNotificationEmail(bounty, "Pending Completion"); // Add notification message this.message.AddBountyNotificationMessage(bounty, "Pending Completion"); return RedirectToAction("Dashboard", "Home", null); } else { string shardName = this.bounty.CharacterShard(bounty.PlacedOnId); var viewModel = new BountyDetailModel { Bounty = bounty, Character = this.characterAddEditViewModel.Character, SelectedShard = this.db.Shards.Where(s => s.Name == shardName).SingleOrDefault().Id, SelectedCharacter = bountyDetailModel.SelectedCharacter }; return View("Details", viewModel); } }
// GET: /Bounty/Details/5 public ActionResult Details(Guid id) { Bounty bounty = this.db.Bounties.Find(id); if(Request.IsAuthenticated) { string shardName = this.bounty.CharacterShard(bounty.PlacedOnId); var viewModel = new BountyDetailModel { Bounty = bounty, Character = this.characterAddEditViewModel.Character, SelectedShard = this.db.Shards.Where(s => s.Name == shardName).SingleOrDefault().Id }; return View(viewModel); } else { var viewModel = new BountyDetailModel { Bounty = bounty }; return View(viewModel); } // Handle for bounty not found page }