Exemple #1
0
        public async Task <ActionResult> TeamDetails([Bind(Include = "Team, Team.TeamUsers,Playbooks,Team.Plays,TeamInstall")] TeamViewModel model)
        {
            var allCountries = await model.GetAllCountry();

            if (ModelState.IsValid)
            {
                var country = allCountries.FirstOrDefault(x => x.Id == model.Team.CountryId);
                model.Team.Country = country.Name;
                var response = await model.CreateUpdateTeam();

                if (response != null)
                {
                    TempData["ErrorMessage"] = "Team saved successully";
                    await model.Load(response.Id);
                }
                else
                {
                    TempData["ErrorMessage"] = "There is some problem in saving team";
                }
            }

            //re-fill data to display -- load differently because the team object is edited by user so if we get team detail it will be overwritten.

            model.CountrySelectList = allCountries.Select(c => new SelectListItem {
                Value = c.Id, Text = c.Name
            }).ToList();
            model.Team.TeamInstall = await model.GetAllTeamInstalledByTeamId(model.Team.Id);

            model.Team.TeamUsers = await model.GetUsersByTeamId(model.Team.Id);

            model.Team.Plays = await model.GetAllPlaysByTeamId(model.Team.Id);

            model.Team.Playbooks = await model.GetAllPlaybooksByTeamId(model.Team.Id);

            return(View(model));
        }