예제 #1
0
        public Task <CommandResponse> Patch([FromBody] UpdateTeamDTO value)
        {
            if (value == null)
            {
                throw new System.ArgumentNullException(nameof(value));
            }

            return(commandProcessor.ProcessAsync <TeamCommandHandler, UpdateTeamCommand, CommandResponse>(new UpdateTeamCommand(value)));
        }
        public IActionResult UpdateTeam(Guid teamId, [FromBody] UpdateTeamDTO dto)
        {
            if (!this._teamService.IsUserTeamManager(teamId, this.GetCurrentUserId()))
            {
                return(Unauthorized("You are not the manager of this team"));
            }

            this._teamService.UpdateTeam(teamId, dto);

            return(Ok());
        }
예제 #3
0
        public IActionResult Put([FromBody] UpdateTeamDTO team, [FromRoute] int id)
        {
            var teamMapped = _mapper.Map <UpdateTeamDTO, Team>(team);

            if (_teamService.Post(teamMapped))
            {
                return(NoContent());
            }
            else
            {
                return(NotFound());
            }
        }
예제 #4
0
 public ActionResult Update(UpdateTeamDTO data)
 {
     if (ModelState.IsValid)
     {
         Team team = _dbContext.Teams.FirstOrDefault(x => x.Id == data.Id);
         team.TeamName    = data.TeamName;
         team.Description = data.Description;
         team.UpdateDate  = DateTime.Now;
         team.Status      = Status.Modified;
         _dbContext.SaveChanges();
         return(RedirectToAction("List"));
     }
     else
     {
         return(View(data));
     }
 }
예제 #5
0
        public ActionResult Update(int id)
        {
            Team team = _dbContext.Teams.FirstOrDefault(x => x.Id == id);

            if (team != null)
            {
                UpdateTeamDTO data = new UpdateTeamDTO();
                data.Id          = team.Id;
                data.TeamName    = team.TeamName;
                data.Description = team.Description;
                return(View(data));
            }
            else
            {
                return(RedirectToAction("List"));
            }
        }
예제 #6
0
        public void UpdateTeam(Guid teamId, UpdateTeamDTO teamDto)
        {
            var team = this.teamRepository.GetById(teamId);

            if (teamDto.Image != team.Image && teamDto.Image != null)
            {
                if (team.Image != null)
                {
                    this.filesService.Delete(Guid.Parse(team.Image.Split("/").Last()));
                }

                team.Image = teamDto.Image;
            }

            team.Name        = teamDto.Name ?? team.Name;
            team.Description = teamDto.Description ?? team.Description;

            this.teamRepository.Update(team);
        }