public void UpdateContributionChannel(R_ContributionChannel t) { //Requires.NotNull(t); //Requires.PropertyNotNegative(t, "ContributionChannelId"); t.Update(); }
// example data public static R_ContributionChannel SampleContributionChannel(int id = 1) { R_ContributionChannel contributionChannel = new R_ContributionChannel(); // int contributionChannel.ContributionChannelId = id; // string contributionChannel.Name = "NameTestValue"; // string contributionChannel.Description = "DescriptionTestValue"; // bool contributionChannel.Active = false; // bool contributionChannel.IsDeleted = false; // int? contributionChannel.CreateBy = 1; // System.DateTime? contributionChannel.CreateOn = new System.DateTime(); // int? contributionChannel.UpdateBy = 1; // System.DateTime? contributionChannel.UpdateOn = new System.DateTime(); return(contributionChannel); }
public void GetContributionChannels_Success_Test() { // Arrange R_ContributionChannel contributionChannel = SampleContributionChannel(1); IList <R_ContributionChannel> list = new List <R_ContributionChannel>(); list.Add(contributionChannel); // create mock for repository var mock = new Mock <IContributionChannelRepository>(); mock.Setup(s => s.GetContributionChannels()).Returns(list); // service ContributionChannelService contributionChannelService = new ContributionChannelService(); ContributionChannelService.Repository = mock.Object; // Act var resultList = contributionChannelService.GetContributionChannels(); ContributionChannelDTO result = resultList.FirstOrDefault(); // Assert Assert.IsNotNull(result); Assert.AreEqual(1, result.ContributionChannelId); }
public ContributionChannelDTO GetContributionChannel(int contributionChannelId) { try { //Requires.NotNegative("contributionChannelId", contributionChannelId); log.Debug("contributionChannelId: " + contributionChannelId + " "); // get R_ContributionChannel t = Repository.GetContributionChannel(contributionChannelId); ContributionChannelDTO dto = new ContributionChannelDTO(t); log.Debug(ContributionChannelDTO.FormatContributionChannelDTO(dto)); return(dto); } catch (System.Exception e) { // error log.Error(e.ToString()); throw; } }
public int AddContributionChannel(ContributionChannelDTO dto) { int id = 0; try { log.Debug(ContributionChannelDTO.FormatContributionChannelDTO(dto)); R_ContributionChannel t = ContributionChannelDTO.ConvertDTOtoEntity(dto); // add id = Repository.AddContributionChannel(t); dto.ContributionChannelId = id; log.Debug("result: 'success', id: " + id); } catch (System.Exception e) { // error log.Error(e.ToString()); throw; } return(id); }
public R_ContributionChannel GetContributionChannel(int contributionChannelId) { //Requires.NotNegative("contributionChannelId", contributionChannelId); R_ContributionChannel t = R_ContributionChannel.SingleOrDefault(contributionChannelId); return(t); }
public ContributionChannelDTO(R_ContributionChannel contributionChannel) { ContributionChannelId = contributionChannel.ContributionChannelId; Name = contributionChannel.Name; Description = contributionChannel.Description; Active = contributionChannel.Active; IsDeleted = contributionChannel.IsDeleted; CreateBy = contributionChannel.CreateBy; CreateOn = contributionChannel.CreateOn; UpdateBy = contributionChannel.UpdateBy; UpdateOn = contributionChannel.UpdateOn; }
public IEnumerable <R_ContributionChannel> GetContributionChannels() { IEnumerable <R_ContributionChannel> results = null; var sql = PetaPoco.Sql.Builder .Select("*") .From("R_ContributionChannel") .Where("IsDeleted = 0") ; results = R_ContributionChannel.Query(sql); return(results); }
public static R_ContributionChannel ConvertDTOtoEntity(ContributionChannelDTO dto) { R_ContributionChannel contributionChannel = new R_ContributionChannel(); contributionChannel.ContributionChannelId = dto.ContributionChannelId; contributionChannel.Name = dto.Name; contributionChannel.Description = dto.Description; contributionChannel.Active = dto.Active; contributionChannel.IsDeleted = dto.IsDeleted; contributionChannel.CreateBy = dto.CreateBy; contributionChannel.CreateOn = dto.CreateOn; contributionChannel.UpdateBy = dto.UpdateBy; contributionChannel.UpdateOn = dto.UpdateOn; return(contributionChannel); }
public IList <R_ContributionChannel> GetContributionChannels(string searchTerm, int pageIndex, int pageSize) { IList <R_ContributionChannel> results = null; var sql = PetaPoco.Sql.Builder .Select("*") .From("R_ContributionChannel") .Where("IsDeleted = 0") .Where( "Name like '%" + searchTerm + "%'" + " or " + "Description like '%" + searchTerm + "%'" ) ; results = R_ContributionChannel.Fetch(pageIndex, pageSize, sql); return(results); }
public IEnumerable <R_ContributionChannel> GetContributionChannelListAdvancedSearch( string name , string description , bool?active ) { IEnumerable <R_ContributionChannel> results = null; var sql = PetaPoco.Sql.Builder .Select("*") .From("R_ContributionChannel") .Where("IsDeleted = 0" + (name != null ? " and Name like '%" + name + "%'" : "") + (description != null ? " and Description like '%" + description + "%'" : "") + (active != null ? " and Active = " + (active == true ? "1" : "0") : "") ) ; results = R_ContributionChannel.Query(sql); return(results); }
public void DeleteContributionChannel(ContributionChannelDTO dto) { try { log.Debug(ContributionChannelDTO.FormatContributionChannelDTO(dto)); R_ContributionChannel t = ContributionChannelDTO.ConvertDTOtoEntity(dto); // delete Repository.DeleteContributionChannel(t); dto.IsDeleted = t.IsDeleted; log.Debug("result: 'success'"); } catch (System.Exception e) { // error log.Error(e.ToString()); throw; } }
public void GetContributionChannel_Success_Test() { // Arrange int id = 1; R_ContributionChannel contributionChannel = SampleContributionChannel(id); // create mock for repository var mock = new Mock <IContributionChannelRepository>(); mock.Setup(s => s.GetContributionChannel(Moq.It.IsAny <int>())).Returns(contributionChannel); // service ContributionChannelService contributionChannelService = new ContributionChannelService(); ContributionChannelService.Repository = mock.Object; // Act ContributionChannelDTO result = contributionChannelService.GetContributionChannel(id); // Assert Assert.IsNotNull(result); Assert.AreEqual(1, result.ContributionChannelId); }
public void UpdateContributionChannel(ContributionChannelDTO dto) { try { //Requires.NotNull(t); //Requires.PropertyNotNegative(t, "ContributionChannelId"); log.Debug(ContributionChannelDTO.FormatContributionChannelDTO(dto)); R_ContributionChannel t = ContributionChannelDTO.ConvertDTOtoEntity(dto); // update Repository.UpdateContributionChannel(t); log.Debug("result: 'success'"); } catch (System.Exception e) { // error log.Error(e.ToString()); throw; } }
public void DeleteContributionChannel(R_ContributionChannel t) { t.IsDeleted = true; t.Update(); }
public int AddContributionChannel(R_ContributionChannel t) { int id = (int)t.Insert(); return(id); }