예제 #1
0
        public void UpdateTeam(R_Team t)
        {
            //Requires.NotNull(t);
            //Requires.PropertyNotNegative(t, "TeamId");

            t.Update();
        }
예제 #2
0
        // 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);
        }
예제 #3
0
        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);
        }
예제 #4
0
        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;
            }
        }
예제 #5
0
        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);
        }
예제 #6
0
        public R_Team GetTeam(int teamId)
        {
            //Requires.NotNegative("teamId", teamId);

            R_Team t = R_Team.SingleOrDefault(teamId);

            return(t);
        }
예제 #7
0
 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;
 }
예제 #8
0
        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);
        }
예제 #9
0
        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);
        }
예제 #10
0
        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);
        }
예제 #11
0
        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;
            }
        }
예제 #12
0
        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);
        }
예제 #13
0
        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);
        }
예제 #14
0
        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;
            }
        }
예제 #15
0
 public void DeleteTeam(R_Team t)
 {
     t.IsDeleted = true;
     t.Update();
 }
예제 #16
0
        public int AddTeam(R_Team t)
        {
            int id = (int)t.Insert();

            return(id);
        }