예제 #1
0
        public MainResponse LinkedExhibitors(HorseExhibitorRequest horseExhibitorRequest)
        {
            var exhibitors = _horseRepository.LinkedExhibitors(horseExhibitorRequest);

            if (exhibitors.getLinkedExhibitors != null && exhibitors.TotalRecords != 0)
            {
                _mainResponse.GetAllLinkedExhibitors = exhibitors;
                _mainResponse.GetAllLinkedExhibitors.TotalRecords = exhibitors.TotalRecords;
                _mainResponse.Success = true;
            }
            else
            {
                _mainResponse.Message = Constants.NO_RECORD_FOUND;
                _mainResponse.Success = false;
            }
            return(_mainResponse);
        }
예제 #2
0
        public GetAllLinkedExhibitors LinkedExhibitors(HorseExhibitorRequest horseExhibitorRequest)
        {
            IEnumerable <GetLinkedExhibitors> data;
            GetAllLinkedExhibitors            getAllLinkedExhibitors = new GetAllLinkedExhibitors();

            data = (from exhibitorHorse in _ObjContext.ExhibitorHorse
                    join exhibitor in _ObjContext.Exhibitors on exhibitorHorse.ExhibitorId equals exhibitor.ExhibitorId into exhibitor1
                    from exhibitor2 in exhibitor1.DefaultIfEmpty()
                    where exhibitorHorse.HorseId == horseExhibitorRequest.HorseId && exhibitorHorse.IsActive == true && exhibitorHorse.IsDeleted == false &&
                    exhibitor2.IsActive == true & exhibitor2.IsDeleted == false
                    select new GetLinkedExhibitors
            {
                ExhibitorId = exhibitorHorse.ExhibitorId,
                ExhibitorName = exhibitor2.FirstName + " " + exhibitor2.LastName,
                BirthYear = exhibitor2.BirthYear
            });
            if (data.Count() != 0)
            {
                if (horseExhibitorRequest.OrderByDescending == true)
                {
                    data = data.OrderByDescending(x => x.GetType().GetProperty(horseExhibitorRequest.OrderBy).GetValue(x));
                }
                else
                {
                    data = data.OrderBy(x => x.GetType().GetProperty(horseExhibitorRequest.OrderBy).GetValue(x));
                }
                getAllLinkedExhibitors.TotalRecords = data.Count();
                if (horseExhibitorRequest.AllRecords)
                {
                    getAllLinkedExhibitors.getLinkedExhibitors = data.ToList();
                }
                else
                {
                    getAllLinkedExhibitors.getLinkedExhibitors = data.Skip((horseExhibitorRequest.Page - 1) * horseExhibitorRequest.Limit).Take(horseExhibitorRequest.Limit).ToList();
                }
            }
            return(getAllLinkedExhibitors);
        }
예제 #3
0
 public IActionResult LinkedExhibitors(HorseExhibitorRequest horseExhibitorRequest)
 {
     _mainResponse = _horseService.LinkedExhibitors(horseExhibitorRequest);
     _jsonString   = Mapper.Convert <GetAllLinkedExhibitors>(_mainResponse);
     return(new OkObjectResult(_jsonString));
 }