public void UpdateTeam(R_Team t) { //Requires.NotNull(t); //Requires.PropertyNotNegative(t, "TeamId"); t.Update(); }
// example data public static R_Team SampleTeam(int id = 1) { R_Team team = new R_Team(); // int team.TeamId = id; // int? team.NucleoId = 1; // string team.Name = "NameTestValue"; // string team.Description = "DescriptionTestValue"; // bool team.Active = false; // bool team.IsDeleted = false; // int? team.CreateBy = 1; // System.DateTime? team.CreateOn = new System.DateTime(); // int? team.UpdateBy = 1; // System.DateTime? team.UpdateOn = new System.DateTime(); return(team); }
public void GetTeams_Success_Test() { // Arrange R_Team team = SampleTeam(1); IList <R_Team> list = new List <R_Team>(); list.Add(team); // create mock for repository var mock = new Mock <ITeamRepository>(); mock.Setup(s => s.GetTeams()).Returns(list); // service TeamService teamService = new TeamService(); TeamService.Repository = mock.Object; // Act var resultList = teamService.GetTeams(); TeamDTO result = resultList.FirstOrDefault(); // Assert Assert.IsNotNull(result); Assert.AreEqual(1, result.TeamId); }
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); }
public R_Team GetTeam(int teamId) { //Requires.NotNegative("teamId", teamId); R_Team t = R_Team.SingleOrDefault(teamId); return(t); }
public TeamDTO(R_Team team) { TeamId = team.TeamId; NucleoId = team.NucleoId; Name = team.Name; Description = team.Description; Active = team.Active; IsDeleted = team.IsDeleted; CreateBy = team.CreateBy; CreateOn = team.CreateOn; UpdateBy = team.UpdateBy; UpdateOn = team.UpdateOn; }
public IEnumerable <R_Team> GetTeams() { IEnumerable <R_Team> results = null; var sql = PetaPoco.Sql.Builder .Select("*") .From("R_Team") .Where("IsDeleted = 0") ; results = R_Team.Query(sql); return(results); }
public static R_Team ConvertDTOtoEntity(TeamDTO dto) { R_Team team = new R_Team(); team.TeamId = dto.TeamId; team.NucleoId = dto.NucleoId; team.Name = dto.Name; team.Description = dto.Description; team.Active = dto.Active; team.IsDeleted = dto.IsDeleted; team.CreateBy = dto.CreateBy; team.CreateOn = dto.CreateOn; team.UpdateBy = dto.UpdateBy; team.UpdateOn = dto.UpdateOn; return(team); }
public IList <R_Team> GetTeams(string searchTerm, int pageIndex, int pageSize) { IList <R_Team> results = null; var sql = PetaPoco.Sql.Builder .Select("*") .From("R_Team") .Where("IsDeleted = 0") .Where( "Name like '%" + searchTerm + "%'" + " or " + "Description like '%" + searchTerm + "%'" ) ; results = R_Team.Fetch(pageIndex, pageSize, sql); return(results); }
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 GetTeam_Success_Test() { // Arrange int id = 1; R_Team team = SampleTeam(id); // create mock for repository var mock = new Mock <ITeamRepository>(); mock.Setup(s => s.GetTeam(Moq.It.IsAny <int>())).Returns(team); // service TeamService teamService = new TeamService(); TeamService.Repository = mock.Object; // Act TeamDTO result = teamService.GetTeam(id); // Assert Assert.IsNotNull(result); Assert.AreEqual(1, result.TeamId); }
public IEnumerable <R_Team> GetTeamListAdvancedSearch( int?nucleoId , string name , string description , bool?active ) { IEnumerable <R_Team> results = null; var sql = PetaPoco.Sql.Builder .Select("*") .From("R_Team") .Where("IsDeleted = 0" + (nucleoId != null ? " and NucleoId like '%" + nucleoId + "%'" : "") + (name != null ? " and Name like '%" + name + "%'" : "") + (description != null ? " and Description like '%" + description + "%'" : "") + (active != null ? " and Active = " + (active == true ? "1" : "0") : "") ) ; results = R_Team.Query(sql); return(results); }
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; } }
public void DeleteTeam(R_Team t) { t.IsDeleted = true; t.Update(); }
public int AddTeam(R_Team t) { int id = (int)t.Insert(); return(id); }