public IEnumerable <Contractor> GetContractors() { var entities = _contractorRepo.GetAll(); var mapper = new ContractorMapper(); return(mapper.Map(entities.ToList())); }
public void AddContractor(Contractor contractor) { var mapper = new ContractorMapper(); var entity = mapper.Map(contractor); _contractorRepo.Add(entity); _contractorRepo.Save(); }
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(); }