public async Task <IActionResult> CreateTeamBasicModel(AdminTeamBasicCreateView model) { if (ModelState.IsValid) { try { var path = _env.WebRootFileProvider.GetFileInfo("/Images/teamBadge.png")?.PhysicalPath; //before adding should check if player is already in a team //check teamname var teamService = _logicFactory.GetTeamService(); //basic info about team. this is always filled in when adding Team t = new Team(); t.TeamName = model.TeamName; t.TeamCaptain = new Player { PlayerID = model.TeamCaptainID }; t.TeamLogo = model.TeamLogoFile != null ? await ImageProcessing.FormFileToResizedByteArrayAsync(model.TeamLogoFile) : ImageProcessing.ImageToByteArray(Image.FromFile(path)); teamService.Add(t); return(PartialView("Team/_Success")); } catch (Exception ex) { _logger.LogError($"Something went wrong trying to add a new team to the database. |Message: {ex.Message} |Stacktrace: {ex.StackTrace}"); return(PartialView("Team/_Failed")); } } else { return(PartialView("Team/_CreateTeamFormPartial", model)); } }
public IActionResult CreateTeamWithoutMembers(AdminTeamCreateView model) { var accountService = _logicFactory.GetAccountService(); AdminTeamBasicCreateView newModel = model; newModel.CaptainsList = accountService.GetAll().Select(a => new SelectListItem { Value = a.AccountPlayer.PlayerID.ToString(), Text = a.AccountName }).ToList(); //return PartialView("_CreateTeamFormPartial"); return(PartialView("Team/_CreateBasicTeamFormPartial", newModel)); }