Example #1
0
        public IEnumerable <Contractor> GetContractors()
        {
            var entities = _contractorRepo.GetAll();
            var mapper   = new ContractorMapper();

            return(mapper.Map(entities.ToList()));
        }
Example #2
0
        public void AddContractor(Contractor contractor)
        {
            var mapper = new ContractorMapper();
            var entity = mapper.Map(contractor);

            _contractorRepo.Add(entity);
            _contractorRepo.Save();
        }
Example #3
0
        public void DeleteContractor(Contractor contractor)
        {
            var mapper         = new ContractorMapper();
            var entity         = mapper.Map(contractor);
            var entityToDelete = _contractorRepo.Get(entity.ContractorId);

            _contractorRepo.Delete(entityToDelete);
            var labourEntity = _labourRepo.Find(x => x.ContractorId == entityToDelete.ContractorId);

            labourEntity.ToList().ForEach(x => x.ContractorId = null);
            _labourRepo.Save();
            _contractorRepo.Save();
        }