示例#1
0
        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));
        }
示例#2
0
 public bool Update(ConsultantModel consultantModel)
 {
     return(LogIfOperationFailed(() =>
     {
         Consultant consultant = ConsultantMapper.ConvertModelToEntity(consultantModel);
         _unitOfWork.ConsultantRepository.InsertOrUpdate(consultant);
         _unitOfWork.Commit();
         return true;
     }, Resources.ExceptionUpdateConsultant, consultantModel.Name));
 }
示例#3
0
        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"));
        }
示例#4
0
        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));
        }