public bool Insert(ConsultantModel consultantModel) { return(LogIfOperationFailed(() => { Consultant consultant = ConsultantMapper.ConvertModelToEntity(consultantModel); _unitOfWork.ConsultantRepository.InsertOrUpdate(consultant); _unitOfWork.Commit(); var existingProviderConsultant = _unitOfWork.ProviderConsultantRepository.GetAll.Where(m => m.ConsultantId == consultant.Id).ToList(); foreach (var ProviderConsultant in existingProviderConsultant) { _unitOfWork.ProviderConsultantRepository.Delete(ProviderConsultant.Id); } _unitOfWork.Commit(); if (consultantModel.ConsultantProviderIds != null) { foreach (var providerId in consultantModel.ConsultantProviderIds) { var providerConsultant = new ProviderConsultant(); providerConsultant.ConsultantId = consultant.Id; providerConsultant.ProviderId = providerId; _unitOfWork.ProviderConsultantRepository.InsertOrUpdate(providerConsultant); } } _unitOfWork.Commit(); return true; }, Resources.ExceptionInsertConsultant, consultantModel.Name)); }
public bool Update(ConsultantModel consultantModel) { return(LogIfOperationFailed(() => { Consultant consultant = ConsultantMapper.ConvertModelToEntity(consultantModel); _unitOfWork.ConsultantRepository.InsertOrUpdate(consultant); _unitOfWork.Commit(); return true; }, Resources.ExceptionUpdateConsultant, consultantModel.Name)); }
public List <ConsultantModel> GetAllConsultants() { return(LogIfOperationFailed(() => { var consultantEntity = _unitOfWork.ConsultantRepository.GetAll; var ConsultantModelList = new List <ConsultantModel>(); // ToDo:Need to implement Automapper consultantEntity.ToList().ForEach(m => { ConsultantModelList.Add(ConsultantMapper.ConvertEntityToModel(m)); }); return ConsultantModelList; }, Resources.ExceptionGetForAllConsultants, "Provider")); }
public ConsultantModel GetConsultant(int id) { return(LogIfOperationFailed(() => { var consultantEntity = _unitOfWork.ConsultantRepository.Find(id); //ToDo:Need to implement Automapper ConsultantModel consultantModel = ConsultantMapper.ConvertEntityToModel(consultantEntity); return consultantModel; }, Resources.ExceptionGetConsultant, id)); }