public void UpdateVehicleType(R_VehicleType t) { //Requires.NotNull(t); //Requires.PropertyNotNegative(t, "VehicleTypeId"); t.Update(); }
// example data public static R_VehicleType SampleVehicleType(int id = 1) { R_VehicleType vehicleType = new R_VehicleType(); // int vehicleType.VehicleTypeId = id; // string vehicleType.Name = "NameTestValue"; // string vehicleType.Description = "DescriptionTestValue"; // bool vehicleType.Active = false; // bool vehicleType.IsDeleted = false; // int? vehicleType.CreateBy = 1; // System.DateTime? vehicleType.CreateOn = new System.DateTime(); // int? vehicleType.UpdateBy = 1; // System.DateTime? vehicleType.UpdateOn = new System.DateTime(); return(vehicleType); }
public VehicleTypeDTO GetVehicleType(int vehicleTypeId) { try { //Requires.NotNegative("vehicleTypeId", vehicleTypeId); log.Debug("vehicleTypeId: " + vehicleTypeId + " "); // get R_VehicleType t = Repository.GetVehicleType(vehicleTypeId); VehicleTypeDTO dto = new VehicleTypeDTO(t); log.Debug(VehicleTypeDTO.FormatVehicleTypeDTO(dto)); return(dto); } catch (System.Exception e) { // error log.Error(e.ToString()); throw; } }
public void GetVehicleTypes_Success_Test() { // Arrange R_VehicleType vehicleType = SampleVehicleType(1); IList <R_VehicleType> list = new List <R_VehicleType>(); list.Add(vehicleType); // create mock for repository var mock = new Mock <IVehicleTypeRepository>(); mock.Setup(s => s.GetVehicleTypes()).Returns(list); // service VehicleTypeService vehicleTypeService = new VehicleTypeService(); VehicleTypeService.Repository = mock.Object; // Act var resultList = vehicleTypeService.GetVehicleTypes(); VehicleTypeDTO result = resultList.FirstOrDefault(); // Assert Assert.IsNotNull(result); Assert.AreEqual(1, result.VehicleTypeId); }
public int AddVehicleType(VehicleTypeDTO dto) { int id = 0; try { log.Debug(VehicleTypeDTO.FormatVehicleTypeDTO(dto)); R_VehicleType t = VehicleTypeDTO.ConvertDTOtoEntity(dto); // add id = Repository.AddVehicleType(t); dto.VehicleTypeId = id; log.Debug("result: 'success', id: " + id); } catch (System.Exception e) { // error log.Error(e.ToString()); throw; } return(id); }
public R_VehicleType GetVehicleType(int vehicleTypeId) { //Requires.NotNegative("vehicleTypeId", vehicleTypeId); R_VehicleType t = R_VehicleType.SingleOrDefault(vehicleTypeId); return(t); }
public VehicleTypeDTO(R_VehicleType vehicleType) { VehicleTypeId = vehicleType.VehicleTypeId; Name = vehicleType.Name; Description = vehicleType.Description; Active = vehicleType.Active; IsDeleted = vehicleType.IsDeleted; CreateBy = vehicleType.CreateBy; CreateOn = vehicleType.CreateOn; UpdateBy = vehicleType.UpdateBy; UpdateOn = vehicleType.UpdateOn; }
public IEnumerable <R_VehicleType> GetVehicleTypes() { IEnumerable <R_VehicleType> results = null; var sql = PetaPoco.Sql.Builder .Select("*") .From("R_VehicleType") .Where("IsDeleted = 0") ; results = R_VehicleType.Query(sql); return(results); }
public static R_VehicleType ConvertDTOtoEntity(VehicleTypeDTO dto) { R_VehicleType vehicleType = new R_VehicleType(); vehicleType.VehicleTypeId = dto.VehicleTypeId; vehicleType.Name = dto.Name; vehicleType.Description = dto.Description; vehicleType.Active = dto.Active; vehicleType.IsDeleted = dto.IsDeleted; vehicleType.CreateBy = dto.CreateBy; vehicleType.CreateOn = dto.CreateOn; vehicleType.UpdateBy = dto.UpdateBy; vehicleType.UpdateOn = dto.UpdateOn; return(vehicleType); }
public IList <R_VehicleType> GetVehicleTypes(string searchTerm, int pageIndex, int pageSize) { IList <R_VehicleType> results = null; var sql = PetaPoco.Sql.Builder .Select("*") .From("R_VehicleType") .Where("IsDeleted = 0") .Where( "Name like '%" + searchTerm + "%'" + " or " + "Description like '%" + searchTerm + "%'" ) ; results = R_VehicleType.Fetch(pageIndex, pageSize, sql); return(results); }
public IEnumerable <R_VehicleType> GetVehicleTypeListAdvancedSearch( string name , string description , bool?active ) { IEnumerable <R_VehicleType> results = null; var sql = PetaPoco.Sql.Builder .Select("*") .From("R_VehicleType") .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_VehicleType.Query(sql); return(results); }
public void DeleteVehicleType(VehicleTypeDTO dto) { try { log.Debug(VehicleTypeDTO.FormatVehicleTypeDTO(dto)); R_VehicleType t = VehicleTypeDTO.ConvertDTOtoEntity(dto); // delete Repository.DeleteVehicleType(t); dto.IsDeleted = t.IsDeleted; log.Debug("result: 'success'"); } catch (System.Exception e) { // error log.Error(e.ToString()); throw; } }
public void GetVehicleType_Success_Test() { // Arrange int id = 1; R_VehicleType vehicleType = SampleVehicleType(id); // create mock for repository var mock = new Mock <IVehicleTypeRepository>(); mock.Setup(s => s.GetVehicleType(Moq.It.IsAny <int>())).Returns(vehicleType); // service VehicleTypeService vehicleTypeService = new VehicleTypeService(); VehicleTypeService.Repository = mock.Object; // Act VehicleTypeDTO result = vehicleTypeService.GetVehicleType(id); // Assert Assert.IsNotNull(result); Assert.AreEqual(1, result.VehicleTypeId); }
public void UpdateVehicleType(VehicleTypeDTO dto) { try { //Requires.NotNull(t); //Requires.PropertyNotNegative(t, "VehicleTypeId"); log.Debug(VehicleTypeDTO.FormatVehicleTypeDTO(dto)); R_VehicleType t = VehicleTypeDTO.ConvertDTOtoEntity(dto); // update Repository.UpdateVehicleType(t); log.Debug("result: 'success'"); } catch (System.Exception e) { // error log.Error(e.ToString()); throw; } }
public void DeleteVehicleType(R_VehicleType t) { t.IsDeleted = true; t.Update(); }
public int AddVehicleType(R_VehicleType t) { int id = (int)t.Insert(); return(id); }