コード例 #1
0
 public ActionResult Edit(int id)
 {
      var team = repo.GetTeam(id);
      if (team != null)
      {
          var vm = new TeamVM { Name = team.Name, Id = team.ID }; 
          return PartialView(vm);
      }
      return View("NotFound");
 }
コード例 #2
0
        public ActionResult Create(TeamVM model)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    model.Name = model.Name.Replace(" ", "");
                    var teamId = _teamManager.SaveTeam(model);
                    return Json(new { Status = "Success" });


                }
                return View(model);
            }
            catch (Exception ex)
            {

            }
            return Json(new { Status = "Error" });
        }
コード例 #3
0
        public ActionResult View(int id)        
        {
            
            var team = repo.GetTeam(id);
            if (team != null)
            {
                var vm = new TeamVM { Id = id, Name = team.Name };

              /*  var teamMembers = team.TeamMembers;
                foreach (var teamMember in teamMembers)
                {
                   var member=new MemberVM { Name = teamMember.User.FirstName + " " + teamMember.User.LastName, EmailAddress=teamMember.User.EmailAddress, JobTitle=teamMember.JobTitle, JoinedDate = teamMember.CreatedDate.ToShortDateString() };
                   member.EmailHash = UserService.GetImageSource(member.EmailAddress);
                   vm.Members.Add(member);
                }*/
       
                return View(vm);
            }
            return View("NotFound");
           
        }/*
コード例 #4
0
        public ActionResult Index()
        {
            try
            {
                var team = repo.GetTeam(TeamID);
                var teamVM = new TeamVM { Name = team.Name, Id = team.ID };

                var teamMembers = team.TeamMembers.OrderBy(s=>s.Member.FirstName).ToList();
                foreach (var member in teamMembers)
                {
                    var memberVM = new MemberVM();
                    memberVM.Name = member.Member.FirstName;
                    memberVM.EmailAddress = member.Member.EmailAddress;
                    memberVM.AvatarHash = UserService.GetAvatarUrl(member.Member.Avatar, 30);
                    memberVM.JoinedDate = member.CreatedDate.ToShortDateString();
                    if(member.Member.LastLoginDate.HasValue)
                        memberVM.LastLoginDate=member.Member.LastLoginDate.Value.ToString("g");

                    teamVM.Members.Add(memberVM);
                }

                var membersNotJoinedList = repo.GetTeamMembersWhoHasntJoined(TeamID).OrderBy(s=>s.EmailAddress).ToList();
                foreach (var member in membersNotJoinedList)
                {
                    var invitation = new MemberInvitation { EmailAddress = member.EmailAddress, DateInvited = member.CreatedDate.ToString("g") };
                    invitation.AvatarHash = UserService.GetImageSource(member.EmailAddress);
                    teamVM.MembersInvited.Add(invitation);
                }  
                return View(teamVM);
            }
            catch (Exception ex)
            {
                log.Error(ex);
                return View("Error");
            }
        }
コード例 #5
0
 public ActionResult Create(TeamVM model)
 {
     try
     {
         if (ModelState.IsValid)
         {
             Team team = new Team { Name = model.Name, ID = model.Id };
             bool isNew = (model.Id == 0);
             if (!isNew)
             {
                 team = repo.GetTeam(model.Id);
                 team.Name = model.Name;                       
             }
             else
             {
                 team.CreatedByID = UserID;
             }
             var result = repo.SaveTeam(team);
             if (result != null)
             {                        
                 if (isNew)
                 {
                     var teamMember = new TeamMember { MemberID = UserID, TeamID = team.ID, CreatedByID = UserID };
                     repo.SaveTeamMember(teamMember);
                 }
                 return Json(new { Status = "Success" });
             }
         }
         return View(model);
     }
     catch(Exception ex)
     {
         log.Error("Error updating team "+model.Id, ex);
     }
     return Json(new { Status = "Error" });
 }    
コード例 #6
0
        public IActionResult View(int id)
        {
            var team = this._teamManager.GetTeam(id);
            if (team != null)
            {
                var vm = new TeamVM { Id = team.Id, Name = team.Name, IsPublic = team.IsPublic, IsRequestingUserTeamOwner = team.IsRequestingUserTeamOwner };

                return View(vm);
            }
            return View("NotFound");

        }
コード例 #7
0
        public async Task<TeamVM> GetTeamInoWithMembers()
        {
            var vm = new TeamVM();

            var team = _teamRepository.GetTeam(this._userSessionHelper.TeamId);
            vm.Name = team.Name;

            var members = await _teamRepository.GetTeamMembers(this._userSessionHelper.TeamId);
            foreach (var teamMemberDto in members)
            {
                teamMemberDto.GravatarUrl = teamMemberDto.EmailAddress.ToGravatarUrl();
            }

            var invitations = await _teamRepository.GetTeamMemberInvitations(this._userSessionHelper.TeamId);
            foreach (var teamMemberDto in invitations)
            {
                teamMemberDto.GravatarUrl = teamMemberDto.EmailAddress.ToGravatarUrl();
            }
            vm.MembersInvited =
                invitations.Select(
                    s =>
                        new MemberInvitation
                        {
                            EmailAddress = s.EmailAddress,
                            AvatarHash = s.GravatarUrl,
                            DateInvited = s.CreatedDate.ToString()
                        }).ToList();


            vm.Members = members;

            return vm;
        }
コード例 #8
0
 public ActionResult MenuHeader()
 {
     var vm = new UserMenuHeaderVM();
     try
     {
         var user = repo.GetUser(UserID);
         if (user != null)
         {
             vm.UserDisplayName = user.FirstName;
             vm.UserAvatarHash = UserService.GetAvatarUrl(user.Avatar);
             var teams = repo.GetTeams(UserID).ToList();
             foreach (var team in teams)
             {
                 var teamVM = new TeamVM { Id = team.ID, Name = team.Name };
                 vm.Teams.Add(teamVM);
                 if (team.ID == TeamID)
                     vm.CurrentTeamName = team.Name;
             }
             vm.SelectedTeam = TeamID;
         }
     }
     catch (Exception ex)
     {
         log.Error(ex);
     }
     return PartialView("Partial/MenuHeader",vm);
 }