public void DeleteSupplierType(SupplierTypeDTO dto) { try { log.Debug(SupplierTypeDTO.FormatSupplierTypeDTO(dto)); R_SupplierType t = SupplierTypeDTO.ConvertDTOtoEntity(dto); // delete Repository.DeleteSupplierType(t); dto.IsDeleted = t.IsDeleted; log.Debug("result: 'success'"); } catch (System.Exception e) { // error log.Error(e.ToString()); throw; } }
public IEnumerable <R_SupplierType> GetSupplierTypeListAdvancedSearch( string name , string description , bool?active ) { IEnumerable <R_SupplierType> results = null; var sql = PetaPoco.Sql.Builder .Select("*") .From("R_SupplierType") .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_SupplierType.Query(sql); return(results); }
public void GetSupplierType_Success_Test() { // Arrange int id = 1; R_SupplierType supplierType = SampleSupplierType(id); // create mock for repository var mock = new Mock <ISupplierTypeRepository>(); mock.Setup(s => s.GetSupplierType(Moq.It.IsAny <int>())).Returns(supplierType); // service SupplierTypeService supplierTypeService = new SupplierTypeService(); SupplierTypeService.Repository = mock.Object; // Act SupplierTypeDTO result = supplierTypeService.GetSupplierType(id); // Assert Assert.IsNotNull(result); Assert.AreEqual(1, result.SupplierTypeId); }
public void UpdateSupplierType(SupplierTypeDTO dto) { try { //Requires.NotNull(t); //Requires.PropertyNotNegative(t, "SupplierTypeId"); log.Debug(SupplierTypeDTO.FormatSupplierTypeDTO(dto)); R_SupplierType t = SupplierTypeDTO.ConvertDTOtoEntity(dto); // update Repository.UpdateSupplierType(t); log.Debug("result: 'success'"); } catch (System.Exception e) { // error log.Error(e.ToString()); throw; } }
public void DeleteSupplierType(R_SupplierType t) { t.IsDeleted = true; t.Update(); }
public int AddSupplierType(R_SupplierType t) { int id = (int)t.Insert(); return(id); }