Beispiel #1
0
        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;
            }
        }
Beispiel #2
0
        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);
        }
Beispiel #3
0
        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);
        }
Beispiel #4
0
        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;
            }
        }
Beispiel #5
0
 public void DeleteSupplierType(R_SupplierType t)
 {
     t.IsDeleted = true;
     t.Update();
 }
Beispiel #6
0
        public int AddSupplierType(R_SupplierType t)
        {
            int id = (int)t.Insert();

            return(id);
        }