public SearchResult <Contractor> FindContractor(string nip, string name)
        {
            if (string.IsNullOrWhiteSpace(nip) && string.IsNullOrWhiteSpace(name))
            {
                throw new ArgumentNullException($"{nameof(nip)}  {nameof(name)}");
            }

            var result = new SearchResult <Contractor>();

            if (string.IsNullOrWhiteSpace(nip))
            {
                result.Data = _contractorRepository.GetAll().Where(x => x.Name.Equals(name, StringComparison.InvariantCultureIgnoreCase));
            }

            if (string.IsNullOrWhiteSpace(name))
            {
                result.Data = _contractorRepository.GetAll().Where(x => x.NIP.Equals(nip, StringComparison.InvariantCultureIgnoreCase));
            }
            else
            {
                result.Data = _contractorRepository.GetAll().Where(
                    x => x.NIP.Equals(nip, StringComparison.InvariantCultureIgnoreCase) &&
                    x.Name.Equals(name, StringComparison.InvariantCultureIgnoreCase));
            }

            return(result);
        }
 public IEnumerable <ContractorListQuery> GetContractorsList()
 {
     return(_ContractorRepository.GetAll().Select(entity =>
                                                  new ContractorListQuery
     {
         Id = entity.Id,
         Nome = entity.Name
     }));
 }
Beispiel #3
0
        public void Index_Returns_All_Contractors()
        {
            var expected = new List <Contractor>();

            contractorRepo.GetAll().Returns(expected);
            var result = underTest.Index();
            var model  = ((ViewResult)result).Model;

            Assert.Same(expected, model);
        }
 public IActionResult Get()
 {
     try
     {
         var list = contractorRepository.GetAll();
         return(new OkObjectResult(list));
     }
     catch (Exception ex)
     {
         LogInfo.LogMessage(enumLogInfoType.Error, ex);
         return(new BadRequestObjectResult(ex));
     }
 }
Beispiel #5
0
        public IActionResult Index()
        {
            var model = contractorRepo.GetAll();

            return(View(model));
        }
 public IEnumerable <ContractorModel> GetContractors()
 {
     return(_repository.GetAll().Select(e => e.GetModel()));
 }
 public List <ContractorDto> GetAll(int pageSize = -1, int pageNo = -1)
 {
     return(repository.GetAll(pageSize, pageNo).ToList());
 }
Beispiel #8
0
 public IEnumerable <Contractor> GetContractors()
 {
     return(_repository.GetAll());
 }