Beispiel #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));
        }