private TeamDTO Create(TeamViewModel viewModel) { try { log.Debug(TeamViewModel.FormatTeamViewModel(viewModel)); TeamDTO team = new TeamDTO(); // copy values viewModel.UpdateDTO(team, null); //RequestContext.Principal.Identity.GetUserId()); // audit team.CreateBy = null; //RequestContext.Principal.Identity.GetUserId(); team.CreateOn = DateTime.UtcNow; // add log.Debug("_teamService.AddTeam - " + TeamDTO.FormatTeamDTO(team)); int id = _teamService.AddTeam(team); team.TeamId = id; log.Debug("result: 'success', id: " + id); return(team); } catch (Exception e) { // error log.Error(e.ToString()); throw; } }
public TeamDTO GetTeam(int teamId) { try { //Requires.NotNegative("teamId", teamId); log.Debug("teamId: " + teamId + " "); // get R_Team t = Repository.GetTeam(teamId); TeamDTO dto = new TeamDTO(t); log.Debug(TeamDTO.FormatTeamDTO(dto)); return(dto); } catch (System.Exception e) { // error log.Error(e.ToString()); throw; } }
public int AddTeam(TeamDTO dto) { int id = 0; try { log.Debug(TeamDTO.FormatTeamDTO(dto)); R_Team t = TeamDTO.ConvertDTOtoEntity(dto); // add id = Repository.AddTeam(t); dto.TeamId = id; log.Debug("result: 'success', id: " + id); } catch (System.Exception e) { // error log.Error(e.ToString()); throw; } return(id); }
private TeamDTO Update(TeamViewModel viewModel) { try { log.Debug(TeamViewModel.FormatTeamViewModel(viewModel)); // get log.Debug("_teamService.GetTeam - teamId: " + viewModel.TeamId + " "); var existingTeam = _teamService.GetTeam(viewModel.TeamId); log.Debug("_teamService.GetTeam - " + TeamDTO.FormatTeamDTO(existingTeam)); if (existingTeam != null) { // copy values viewModel.UpdateDTO(existingTeam, null); //RequestContext.Principal.Identity.GetUserId()); // update log.Debug("_teamService.UpdateTeam - " + TeamDTO.FormatTeamDTO(existingTeam)); _teamService.UpdateTeam(existingTeam); log.Debug("result: 'success'"); } else { log.Error("existingTeam: null, TeamId: " + viewModel.TeamId); } return(existingTeam); } catch (Exception e) { // error log.Error(e.ToString()); throw; } }
public void DeleteTeam(TeamDTO dto) { try { log.Debug(TeamDTO.FormatTeamDTO(dto)); R_Team t = TeamDTO.ConvertDTOtoEntity(dto); // delete Repository.DeleteTeam(t); dto.IsDeleted = t.IsDeleted; log.Debug("result: 'success'"); } catch (System.Exception e) { // error log.Error(e.ToString()); throw; } }
public void UpdateTeam(TeamDTO dto) { try { //Requires.NotNull(t); //Requires.PropertyNotNegative(t, "TeamId"); log.Debug(TeamDTO.FormatTeamDTO(dto)); R_Team t = TeamDTO.ConvertDTOtoEntity(dto); // update Repository.UpdateTeam(t); log.Debug("result: 'success'"); } catch (System.Exception e) { // error log.Error(e.ToString()); throw; } }