Exemplo n.º 1
0
        public ActionResult Details(int?id)
        {
            ViewBag.Message = "成员信息";
            TeamMemberDTO dto = new TeamMemberDTO();

            if (id != null)
            {
                dto = _team.GetMemberById((int)id);
            }
            return(View(dto));
        }
Exemplo n.º 2
0
        public List <TeamMemberDTO> GetAllMembers()
        {
            var list = new List <TeamMemberDTO>();

            db.Members.ToList().ForEach(p =>
            {
                TeamMemberDTO dto = Mapper.Map <TeamMember, TeamMemberDTO>(p);
                list.Add(dto);
            });
            // Mapper.Map<TeamMember, TeamMemberDTO>(new TeamMember());
            return(list);
        }
        public async Task <ActionResult <TeamMemberDTO> > NewTeamMember(int id, TeamMemberDTO teamMemberDTO)
        {
            if (await _teamRepository.TeamMemberExists(id, teamMemberDTO.Name))
            {
                return(BadRequest($"Summoner {teamMemberDTO.Name} already exist in team {id}"));
            }

            TeamMember newTeamMember = _mapper.Map <TeamMember>(teamMemberDTO);

            var member = await _teamRepository.NewTeamMember(id, newTeamMember);

            return(teamMemberDTO);
        }
Exemplo n.º 4
0
        public async Task <IActionResult> GetAnotherTeamMemberInfo(int id)
        {
            TeamMemberDTO teamMember = await memberService.GetTeamMemberOrNullAsync(id);

            if (teamMember == null)
            {
                throw new BadRequestException("The user doesn't have a team!");
            }

            return(new JsonResult(new
            {
                UserId = teamMember.Id,
                TeamId = teamMember.TeamId,
                YouTubeId = teamMember.YouTubeId
            }));
        }
Exemplo n.º 5
0
        public async Task <IActionResult> GetCurrentTeamMemberInfo()
        {
            TeamMemberDTO teamMember = await memberService.GetTeamMemberOrNullAsync(User.GetUserId());

            if (teamMember == null)
            {
                throw new BadRequestException("You don't have a team!");
            }

            return(new JsonResult(new
            {
                UserId = teamMember.Id,
                TeamId = teamMember.TeamId,
                YouTubeId = teamMember.YouTubeId
            }));
        }
Exemplo n.º 6
0
        public bool CreateOrUpdateTeamMember(TeamMemberDTO teamMemberInsert, string UserId)
        {
            if (teamMemberInsert.Id > 0)
            {
                var TeamMember = new TeamMember
                {
                    Id             = teamMemberInsert.Id,
                    IsRemove       = false,
                    Team           = _uow.TeamRepository.Get(x => x.Id == teamMemberInsert.TeamId && !x.IsRemove).FirstOrDefault(),
                    TeamId         = teamMemberInsert.TeamId,
                    TeamMemberName = teamMemberInsert.TeamMemberName,
                    ModifiedBy     = UserId,
                    ModifiedDate   = DateTime.Now
                };
            }
            else
            {
                var checkTotalMemberInTeam = _uow.TeamMemberRepository.Get(x => x.TeamId == teamMemberInsert.TeamId).ToList();

                if (checkTotalMemberInTeam.Count < 3)
                {
                    var TeamMember = new TeamMember
                    {
                        IsRemove       = false,
                        Team           = _uow.TeamRepository.Get(x => x.Id == teamMemberInsert.TeamId && !x.IsRemove).FirstOrDefault(),
                        TeamId         = teamMemberInsert.TeamId,
                        TeamMemberName = teamMemberInsert.TeamMemberName,
                        CreatedBy      = UserId,
                        CreateDate     = DateTime.Now
                    };

                    _uow.TeamMemberRepository.Insert(TeamMember);
                    _uow.TeamMemberRepository.Save();

                    return(true);
                }

                else
                {
                    return(false);
                }
            }
        }
        public async Task <IHttpActionResult> PostTeamMember(TeamMemberDTO teamMember)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            Person userperson = await db.People.SingleOrDefaultAsync(p => p.ID == 0);

            if (teamMember.Main)
            {
                var staffID      = teamMember.StaffID;
                var otherRecords = db.People.Single(p => p.ID == staffID).MemberOf;
                foreach (var otherRecord in otherRecords)
                {
                    if (otherRecord.Main)
                    {
                        otherRecord.Main     = false;
                        otherRecord.Modified = DateTime.Now;
                        otherRecord.Modifier = userperson;
                    }
                }
            }

            TeamMember mem = new TeamMember();

            mem.StaffID  = teamMember.StaffID;
            mem.TeamID   = teamMember.TeamID;
            mem.Active   = teamMember.Active;
            mem.Main     = teamMember.Main;
            mem.Created  = DateTime.Now;
            mem.Creator  = userperson;
            mem.Modified = DateTime.Now;
            mem.Modifier = userperson;

            db.TeamMembers.Add(mem);
            await db.SaveChangesAsync();

            return(CreatedAtRoute("DefaultApi", new { id = mem.ID }, teamMember));
        }
Exemplo n.º 8
0
        public int UpdateMember(TeamMemberDTO m)
        {
            TeamMember member;

            if (m.ID == 0)
            {
                member                = Mapper.Map <TeamMemberDTO, TeamMember>(m);
                member.HeaderImage    = "image/default.png";
                member.CreatedTime    = DateTime.Now;
                member.EntryDate      = DateTime.Now;
                member.LastUpdateTime = DateTime.Now;
                member.version        = "1";
                member.Sex            = "男";
                member.Transaction    = Guid.NewGuid().ToString();
                db.Members.Add(member);
                db.SaveChanges();
                return(1);
            }
            else
            {
                return(0);
            }
        }
Exemplo n.º 9
0
        public TeamMemberDTO GetMemberById(int id)
        {
            TeamMemberDTO dto = Mapper.Map <TeamMember, TeamMemberDTO>(db.Members.Find(id));

            return(dto);
        }
Exemplo n.º 10
0
        public ActionResult AddMember(TeamMemberDTO dto)
        {
            _team.UpdateMember(dto);

            return(RedirectToAction("Index"));;
        }
Exemplo n.º 11
0
 public int UpdateMember(TeamMemberDTO m)
 {
     return(teamMemberBC.UpdateMember(m));
 }
 public async Task UpdateMember(TeamMemberDTO teamMember)
 {
     await _teamMemberService.Update(teamMember);
 }