Пример #1
0
        public IEnumerable <Contractor> GetContractors()
        {
            var entities = _contractorRepo.GetAll();
            var mapper   = new ContractorMapper();

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

            _contractorRepo.Add(entity);
            _contractorRepo.Save();
        }
Пример #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();
        }