public TaskTypeDTO GetTaskType(int taskTypeId) { try { //Requires.NotNegative("taskTypeId", taskTypeId); log.Debug("taskTypeId: " + taskTypeId + " "); // get R_TaskType t = Repository.GetTaskType(taskTypeId); TaskTypeDTO dto = new TaskTypeDTO(t); log.Debug(TaskTypeDTO.FormatTaskTypeDTO(dto)); return(dto); } catch (System.Exception e) { // error log.Error(e.ToString()); throw; } }
public int AddTaskType(TaskTypeDTO dto) { int id = 0; try { log.Debug(TaskTypeDTO.FormatTaskTypeDTO(dto)); R_TaskType t = TaskTypeDTO.ConvertDTOtoEntity(dto); // add id = Repository.AddTaskType(t); dto.TaskTypeId = id; log.Debug("result: 'success', id: " + id); } catch (System.Exception e) { // error log.Error(e.ToString()); throw; } return(id); }
public void UpdateTaskType(R_TaskType t) { //Requires.NotNull(t); //Requires.PropertyNotNegative(t, "TaskTypeId"); t.Update(); }
// example data public static R_TaskType SampleTaskType(int id = 1) { R_TaskType taskType = new R_TaskType(); // int taskType.TaskTypeId = id; // string taskType.Name = "NameTestValue"; // string taskType.Description = "DescriptionTestValue"; // bool taskType.Active = false; // bool taskType.IsDeleted = false; // int? taskType.CreateBy = 1; // System.DateTime? taskType.CreateOn = new System.DateTime(); // int? taskType.UpdateBy = 1; // System.DateTime? taskType.UpdateOn = new System.DateTime(); return(taskType); }
public void GetTaskTypes_Success_Test() { // Arrange R_TaskType taskType = SampleTaskType(1); IList <R_TaskType> list = new List <R_TaskType>(); list.Add(taskType); // create mock for repository var mock = new Mock <ITaskTypeRepository>(); mock.Setup(s => s.GetTaskTypes()).Returns(list); // service TaskTypeService taskTypeService = new TaskTypeService(); TaskTypeService.Repository = mock.Object; // Act var resultList = taskTypeService.GetTaskTypes(); TaskTypeDTO result = resultList.FirstOrDefault(); // Assert Assert.IsNotNull(result); Assert.AreEqual(1, result.TaskTypeId); }
public R_TaskType GetTaskType(int taskTypeId) { //Requires.NotNegative("taskTypeId", taskTypeId); R_TaskType t = R_TaskType.SingleOrDefault(taskTypeId); return(t); }
public TaskTypeDTO(R_TaskType taskType) { TaskTypeId = taskType.TaskTypeId; Name = taskType.Name; Description = taskType.Description; Active = taskType.Active; IsDeleted = taskType.IsDeleted; CreateBy = taskType.CreateBy; CreateOn = taskType.CreateOn; UpdateBy = taskType.UpdateBy; UpdateOn = taskType.UpdateOn; }
public IEnumerable <R_TaskType> GetTaskTypes() { IEnumerable <R_TaskType> results = null; var sql = PetaPoco.Sql.Builder .Select("*") .From("R_TaskType") .Where("IsDeleted = 0") ; results = R_TaskType.Query(sql); return(results); }
public static R_TaskType ConvertDTOtoEntity(TaskTypeDTO dto) { R_TaskType taskType = new R_TaskType(); taskType.TaskTypeId = dto.TaskTypeId; taskType.Name = dto.Name; taskType.Description = dto.Description; taskType.Active = dto.Active; taskType.IsDeleted = dto.IsDeleted; taskType.CreateBy = dto.CreateBy; taskType.CreateOn = dto.CreateOn; taskType.UpdateBy = dto.UpdateBy; taskType.UpdateOn = dto.UpdateOn; return(taskType); }
public IList <R_TaskType> GetTaskTypes(string searchTerm, int pageIndex, int pageSize) { IList <R_TaskType> results = null; var sql = PetaPoco.Sql.Builder .Select("*") .From("R_TaskType") .Where("IsDeleted = 0") .Where( "Name like '%" + searchTerm + "%'" + " or " + "Description like '%" + searchTerm + "%'" ) ; results = R_TaskType.Fetch(pageIndex, pageSize, sql); return(results); }
public void DeleteTaskType(TaskTypeDTO dto) { try { log.Debug(TaskTypeDTO.FormatTaskTypeDTO(dto)); R_TaskType t = TaskTypeDTO.ConvertDTOtoEntity(dto); // delete Repository.DeleteTaskType(t); dto.IsDeleted = t.IsDeleted; log.Debug("result: 'success'"); } catch (System.Exception e) { // error log.Error(e.ToString()); throw; } }
public IEnumerable <R_TaskType> GetTaskTypeListAdvancedSearch( string name , string description , bool?active ) { IEnumerable <R_TaskType> results = null; var sql = PetaPoco.Sql.Builder .Select("*") .From("R_TaskType") .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_TaskType.Query(sql); return(results); }
public void GetTaskType_Success_Test() { // Arrange int id = 1; R_TaskType taskType = SampleTaskType(id); // create mock for repository var mock = new Mock <ITaskTypeRepository>(); mock.Setup(s => s.GetTaskType(Moq.It.IsAny <int>())).Returns(taskType); // service TaskTypeService taskTypeService = new TaskTypeService(); TaskTypeService.Repository = mock.Object; // Act TaskTypeDTO result = taskTypeService.GetTaskType(id); // Assert Assert.IsNotNull(result); Assert.AreEqual(1, result.TaskTypeId); }
public void UpdateTaskType(TaskTypeDTO dto) { try { //Requires.NotNull(t); //Requires.PropertyNotNegative(t, "TaskTypeId"); log.Debug(TaskTypeDTO.FormatTaskTypeDTO(dto)); R_TaskType t = TaskTypeDTO.ConvertDTOtoEntity(dto); // update Repository.UpdateTaskType(t); log.Debug("result: 'success'"); } catch (System.Exception e) { // error log.Error(e.ToString()); throw; } }
public void DeleteTaskType(R_TaskType t) { t.IsDeleted = true; t.Update(); }
public int AddTaskType(R_TaskType t) { int id = (int)t.Insert(); return(id); }