public ActionResult Create(BracketFriends bracketFriends) { if (Authenticate.IsAuthenticated()) { List <Guid> ids = bracketFriends.SelectedPlayerIds.ToList(); Bracket bracket = bracketFriends.Bracket; if (bracketFriends.File != null) { bracket.ImageSource = bracketFriends.File.FileName; string target = Path.Combine(Server.MapPath("~/images"), Path.GetFileName(bracketFriends.File.FileName)); if (!System.IO.File.Exists(target)) { bracketFriends.File.SaveAs(target); ViewBag.Message = "File Uploaded Successfully"; } else { ViewBag.Message = "File did not upload"; } } bracket.CurrentDivision = 1; bracket.Matches = Helper.ObjectManipulation.DivideIntoMatches(ids); bracket.Moderator = (User)Session["user"]; bracket.OriginalRoundCount = bracket.Matches.Count; BracketManager.Insert(bracket); return(RedirectToAction("Details", new { @id = bracket.Id })); } else { return(RedirectToAction("Login", "User", new { returnurl = HttpContext.Request.Url })); } }