public IList <Dalyan.Entities.Models.SampleTable> Handler(SampleTableGetAllQuery query)
 {
     try
     {
         var result = _db.SampleTable.Include("Company").Where(x => x.IsDeleted == false).AsEnumerable().ToList();
         Mapper.CreateMap <Dalyan.Db.Company, Dalyan.Entities.Models.Company>();
         Mapper.CreateMap <Dalyan.Db.SampleTable, Dalyan.Entities.Models.SampleTable>().ForMember(c => c.Company, d => d.MapFrom(s => s.Company));
         return(Mapper.Map <IEnumerable <Dalyan.Db.SampleTable>, IEnumerable <Dalyan.Entities.Models.SampleTable> >(result).ToList());
     }
     catch (Exception ex)
     {
         throw new ExceptionLog(LogType.DATABASE_SELECT, LogLevel.ERROR, ex, "GetAllQueryHandler");
     }
 }
Exemple #2
0
 public ServiceResult <IList <SampleTable> > GetAll()
 {
     try
     {
         IMediator service = _container.GetInstance <IMediator>();
         var       query   = new SampleTableGetAllQuery();
         return(new ServiceResult <IList <SampleTable> >(service.Proccess(query), message: ClientErrorMessage.Success(), state: ServiceResultStates.SUCCESS));
     }
     catch (ExceptionLog ex)
     {
         LoggerService.Logger.Log(_container, ex);
         return(new ServiceResult <IList <SampleTable> >(result: null, message: ClientErrorMessage.Error(), state: ServiceResultStates.ERROR));
     }
 }
 	public ServiceResult<IList<SampleTable>> GetAll()
 	{
 		try
 		{
 			IMediator service = _container.GetInstance<IMediator>();
 			var query = new SampleTableGetAllQuery();
 			return new ServiceResult<IList<SampleTable>>(service.Proccess(query), message: ClientErrorMessage.Success(), state: ServiceResultStates.SUCCESS);
 		}
 		catch(ExceptionLog ex)
 		{
 			LoggerService.Logger.Log(_container, ex);
 			return new ServiceResult<IList<SampleTable>>(result: null, message: ClientErrorMessage.Error(), state: ServiceResultStates.ERROR);
 		}
 	}