Esempio n. 1
0
        public async Task <ActionResult> SaveInstall(string teamId, [Bind(Include = "Id,Date,TeamInstallId,Title,Description,Active,CoachId")] TeamInstallDTO teamInstall)
        {
            TeamViewModel model = new TeamViewModel();

            teamInstall.TeamId = teamId.Trim();
            if (!string.IsNullOrEmpty(Request.Form["DateIssue"]))
            {
                teamInstall.Date = Convert.ToDateTime(Request.Form["DateIssue"]);
            }
            if (await model.CreateUpdateTestInstall(teamInstall))
            {
                if (!string.IsNullOrEmpty(teamInstall.Id))
                {
                    List <TeamUser> teamUsers = await model.GetUsersByTeamId(teamInstall.TeamId);

                    foreach (var user in teamUsers)
                    {
                        var emailResponse = await model.SendInstallNotification(new EmailDTO { To = user.Email, Subject = "PlayBool5 Install Notification", Body = "New Install '" + teamInstall.Title + "' is created in your team" });
                    }
                }

                TempData["ErrorMessage"] = "Install added to team";
            }
            else
            {
                TempData["ErrorMessage"] = "There is some problem in adding install to team";
            }

            ActionResult result;

            result = RedirectToAction("Install", new { teamId = teamId });
            return(await Task.FromResult(result));
        }
Esempio n. 2
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));
        }