public ExperimentalPhaseLogDTO GetExperimentalPhaseLog(int experimentalPhaseLogId) { try { //Requires.NotNegative("experimentalPhaseLogId", experimentalPhaseLogId); log.Debug("experimentalPhaseLogId: " + experimentalPhaseLogId + " "); // get R_ExperimentalPhaseLog t = Repository.GetExperimentalPhaseLog(experimentalPhaseLogId); ExperimentalPhaseLogDTO dto = new ExperimentalPhaseLogDTO(t); log.Debug(ExperimentalPhaseLogDTO.FormatExperimentalPhaseLogDTO(dto)); return(dto); } catch (System.Exception e) { // error log.Error(e.ToString()); throw; } }
public int AddExperimentalPhaseLog(ExperimentalPhaseLogDTO dto) { int id = 0; try { log.Debug(ExperimentalPhaseLogDTO.FormatExperimentalPhaseLogDTO(dto)); R_ExperimentalPhaseLog t = ExperimentalPhaseLogDTO.ConvertDTOtoEntity(dto); // add id = Repository.AddExperimentalPhaseLog(t); dto.ExperimentalPhaseLogId = id; log.Debug("result: 'success', id: " + id); } catch (System.Exception e) { // error log.Error(e.ToString()); throw; } return(id); }
public IEnumerable <R_ExperimentalPhaseLog> GetExperimentalPhaseLogListAdvancedSearch( int?nucleoId , System.DateTime?logDateFrom , System.DateTime?logDateTo , string task , string activityDescription , string managerName , string volunteerName , bool?volunteerConfirmation , int?documentId ) { IEnumerable <R_ExperimentalPhaseLog> results = null; var sql = PetaPoco.Sql.Builder .Select("*") .From("R_ExperimentalPhaseLog") .Where("IsDeleted = 0" + (nucleoId != null ? " and NucleoId like '%" + nucleoId + "%'" : "") + (logDateFrom != null ? " and LogDate >= '" + logDateFrom.Value.ToShortDateString() + "'" : "") + (logDateTo != null ? " and LogDate <= '" + logDateTo.Value.ToShortDateString() + "'" : "") + (task != null ? " and Task like '%" + task + "%'" : "") + (activityDescription != null ? " and ActivityDescription like '%" + activityDescription + "%'" : "") + (managerName != null ? " and ManagerName like '%" + managerName + "%'" : "") + (volunteerName != null ? " and VolunteerName like '%" + volunteerName + "%'" : "") + (volunteerConfirmation != null ? " and VolunteerConfirmation = " + (volunteerConfirmation == true ? "1" : "0") : "") + (documentId != null ? " and DocumentId like '%" + documentId + "%'" : "") ) ; results = R_ExperimentalPhaseLog.Query(sql); return(results); }
public void UpdateExperimentalPhaseLog(R_ExperimentalPhaseLog t) { //Requires.NotNull(t); //Requires.PropertyNotNegative(t, "ExperimentalPhaseLogId"); t.Update(); }
// example data public static R_ExperimentalPhaseLog SampleExperimentalPhaseLog(int id = 1) { R_ExperimentalPhaseLog experimentalPhaseLog = new R_ExperimentalPhaseLog(); // int experimentalPhaseLog.ExperimentalPhaseLogId = id; // int? experimentalPhaseLog.NucleoId = 1; // System.DateTime experimentalPhaseLog.LogDate = new System.DateTime(); // string experimentalPhaseLog.Task = "TaskTestValue"; // string experimentalPhaseLog.ActivityDescription = "ActivityDescriptionTestValue"; // string experimentalPhaseLog.ManagerName = "ManagerNameTestValue"; // string experimentalPhaseLog.VolunteerName = "VolunteerNameTestValue"; // bool experimentalPhaseLog.VolunteerConfirmation = false; // int? experimentalPhaseLog.DocumentId = 1; // bool experimentalPhaseLog.IsDeleted = false; // int? experimentalPhaseLog.CreateBy = 1; // System.DateTime? experimentalPhaseLog.CreateOn = new System.DateTime(); // int? experimentalPhaseLog.UpdateBy = 1; // System.DateTime? experimentalPhaseLog.UpdateOn = new System.DateTime(); return(experimentalPhaseLog); }
public void GetExperimentalPhaseLogs_Success_Test() { // Arrange R_ExperimentalPhaseLog experimentalPhaseLog = SampleExperimentalPhaseLog(1); IList <R_ExperimentalPhaseLog> list = new List <R_ExperimentalPhaseLog>(); list.Add(experimentalPhaseLog); // create mock for repository var mock = new Mock <IExperimentalPhaseLogRepository>(); mock.Setup(s => s.GetExperimentalPhaseLogs()).Returns(list); // service ExperimentalPhaseLogService experimentalPhaseLogService = new ExperimentalPhaseLogService(); ExperimentalPhaseLogService.Repository = mock.Object; // Act var resultList = experimentalPhaseLogService.GetExperimentalPhaseLogs(); ExperimentalPhaseLogDTO result = resultList.FirstOrDefault(); // Assert Assert.IsNotNull(result); Assert.AreEqual(1, result.ExperimentalPhaseLogId); }
public R_ExperimentalPhaseLog GetExperimentalPhaseLog(int experimentalPhaseLogId) { //Requires.NotNegative("experimentalPhaseLogId", experimentalPhaseLogId); R_ExperimentalPhaseLog t = R_ExperimentalPhaseLog.SingleOrDefault(experimentalPhaseLogId); return(t); }
public IEnumerable <R_ExperimentalPhaseLog> GetExperimentalPhaseLogs() { IEnumerable <R_ExperimentalPhaseLog> results = null; var sql = PetaPoco.Sql.Builder .Select("*") .From("R_ExperimentalPhaseLog") .Where("IsDeleted = 0") ; results = R_ExperimentalPhaseLog.Query(sql); return(results); }
public ExperimentalPhaseLogDTO(R_ExperimentalPhaseLog experimentalPhaseLog) { ExperimentalPhaseLogId = experimentalPhaseLog.ExperimentalPhaseLogId; NucleoId = experimentalPhaseLog.NucleoId; LogDate = experimentalPhaseLog.LogDate; Task = experimentalPhaseLog.Task; ActivityDescription = experimentalPhaseLog.ActivityDescription; ManagerName = experimentalPhaseLog.ManagerName; VolunteerName = experimentalPhaseLog.VolunteerName; VolunteerConfirmation = experimentalPhaseLog.VolunteerConfirmation; DocumentId = experimentalPhaseLog.DocumentId; IsDeleted = experimentalPhaseLog.IsDeleted; CreateBy = experimentalPhaseLog.CreateBy; CreateOn = experimentalPhaseLog.CreateOn; UpdateBy = experimentalPhaseLog.UpdateBy; UpdateOn = experimentalPhaseLog.UpdateOn; }
public IList <R_ExperimentalPhaseLog> GetExperimentalPhaseLogs(string searchTerm, int pageIndex, int pageSize) { IList <R_ExperimentalPhaseLog> results = null; var sql = PetaPoco.Sql.Builder .Select("*") .From("R_ExperimentalPhaseLog") .Where("IsDeleted = 0") .Where( "Task like '%" + searchTerm + "%'" + " or " + "ActivityDescription like '%" + searchTerm + "%'" + " or " + "ManagerName like '%" + searchTerm + "%'" + " or " + "VolunteerName like '%" + searchTerm + "%'" ) ; results = R_ExperimentalPhaseLog.Fetch(pageIndex, pageSize, sql); return(results); }
public static R_ExperimentalPhaseLog ConvertDTOtoEntity(ExperimentalPhaseLogDTO dto) { R_ExperimentalPhaseLog experimentalPhaseLog = new R_ExperimentalPhaseLog(); experimentalPhaseLog.ExperimentalPhaseLogId = dto.ExperimentalPhaseLogId; experimentalPhaseLog.NucleoId = dto.NucleoId; experimentalPhaseLog.LogDate = dto.LogDate; experimentalPhaseLog.Task = dto.Task; experimentalPhaseLog.ActivityDescription = dto.ActivityDescription; experimentalPhaseLog.ManagerName = dto.ManagerName; experimentalPhaseLog.VolunteerName = dto.VolunteerName; experimentalPhaseLog.VolunteerConfirmation = dto.VolunteerConfirmation; experimentalPhaseLog.DocumentId = dto.DocumentId; experimentalPhaseLog.IsDeleted = dto.IsDeleted; experimentalPhaseLog.CreateBy = dto.CreateBy; experimentalPhaseLog.CreateOn = dto.CreateOn; experimentalPhaseLog.UpdateBy = dto.UpdateBy; experimentalPhaseLog.UpdateOn = dto.UpdateOn; return(experimentalPhaseLog); }
public void DeleteExperimentalPhaseLog(ExperimentalPhaseLogDTO dto) { try { log.Debug(ExperimentalPhaseLogDTO.FormatExperimentalPhaseLogDTO(dto)); R_ExperimentalPhaseLog t = ExperimentalPhaseLogDTO.ConvertDTOtoEntity(dto); // delete Repository.DeleteExperimentalPhaseLog(t); dto.IsDeleted = t.IsDeleted; log.Debug("result: 'success'"); } catch (System.Exception e) { // error log.Error(e.ToString()); throw; } }
public void GetExperimentalPhaseLog_Success_Test() { // Arrange int id = 1; R_ExperimentalPhaseLog experimentalPhaseLog = SampleExperimentalPhaseLog(id); // create mock for repository var mock = new Mock <IExperimentalPhaseLogRepository>(); mock.Setup(s => s.GetExperimentalPhaseLog(Moq.It.IsAny <int>())).Returns(experimentalPhaseLog); // service ExperimentalPhaseLogService experimentalPhaseLogService = new ExperimentalPhaseLogService(); ExperimentalPhaseLogService.Repository = mock.Object; // Act ExperimentalPhaseLogDTO result = experimentalPhaseLogService.GetExperimentalPhaseLog(id); // Assert Assert.IsNotNull(result); Assert.AreEqual(1, result.ExperimentalPhaseLogId); }
public void UpdateExperimentalPhaseLog(ExperimentalPhaseLogDTO dto) { try { //Requires.NotNull(t); //Requires.PropertyNotNegative(t, "ExperimentalPhaseLogId"); log.Debug(ExperimentalPhaseLogDTO.FormatExperimentalPhaseLogDTO(dto)); R_ExperimentalPhaseLog t = ExperimentalPhaseLogDTO.ConvertDTOtoEntity(dto); // update Repository.UpdateExperimentalPhaseLog(t); log.Debug("result: 'success'"); } catch (System.Exception e) { // error log.Error(e.ToString()); throw; } }
public void DeleteExperimentalPhaseLog(R_ExperimentalPhaseLog t) { t.IsDeleted = true; t.Update(); }
public int AddExperimentalPhaseLog(R_ExperimentalPhaseLog t) { int id = (int)t.Insert(); return(id); }