Пример #1
0
        public IEnumerable <Subject> Read(SubjectFilter filter)
        {
            IEnumerable <Subject> subjects = this.Context
                                             .Set <Subject>()
                                             .Where(x => x.Id == filter.Id || x.Description.Contains(filter.Description));

            return(subjects);
        }
        public PageModelResult <Subject> Read(SubjectFilter filter)
        {
            PageModelResult <Subject> model    = new PageModelResult <Subject>(filter);
            IEnumerable <Subject>     subjects = this.repository.Read(filter);

            model.RowCount  = subjects.Count();
            model.PageIndex = filter.PageIndex;
            model.Data      = subjects.Skip(filter.Skip).Take(filter.Take);

            return(model);
        }
        public static SubjectDto MapTo(SubjectFilter filter)
        {
            SubjectDto result = new SubjectDto();

            result.Id          = filter.Id;
            result.Description = filter.Description;
            result.PageIndex   = filter.PageIndex;
            result.PageSize    = filter.PageSize;
            result.Protocol    = filter.Protocol;

            return(result);
        }
Пример #4
0
        public PageOperationResponse <SubjectMessage> Read(SubjectFilter filter)
        {
            PageOperationResponse <SubjectMessage> response = null;

            try
            {
                var model = this.entityService.Read(filter);
                response = SubjectMapper.MapTo(model);
            }
            catch (Exception ex)
            {
                response = base.CreatePageErrorResponse <SubjectMessage>(ex, filter.Protocol, OperationStatusType.SystemError);
            }

            return(response);
        }
 public IHttpActionResult Get([FromUri] SubjectFilter filter)
 {
     try
     {
         List <SubjectModel> list = _repository.GetAll(filter).Select(MapEntityToModel).OrderBy(s => s.Id).ToList();
         var content = new EntitiesListResult <SubjectModel>
         {
             Data     = list,
             Page     = -1,
             PageSize = -1
         };
         ;
         content.Total = list.Count;
         return(Ok(content));
     }
     catch (Exception e)
     {
         return(HandleException(e));
     }
 }
Пример #6
0
 public PageOperationResponse <SubjectMessage> Get(SubjectFilter filter)
 {
     return(this.application.Read(filter));
 }
Пример #7
0
        public List <Subject> GetAll(SubjectFilter filter)
        {
            IEnumerable <Subject> result = base.GetAll();

            if (filter == null)
            {
                return(result.ToList());
            }

            if (!string.IsNullOrEmpty(filter.Title))
            {
                result = result.Where(s => s.Title.ToUpperInvariant().Contains(filter.Title.ToUpperInvariant()));
            }

            if (!string.IsNullOrEmpty(filter.FormsOfControl))
            {
                result = result.Where(s => s.FormsOfControl.Any(f => f.Id == filter.FormsOfControl));
            }

            if (!string.IsNullOrEmpty(filter.Module))
            {
                result = result.Where(s => s.Modules.Any(f => f.Id == filter.Module));
            }

            if (!string.IsNullOrEmpty(filter.StudyProgramme))
            {
                result = result.Where(s => s.StudyProgramme?.Title?.ToUpperInvariant().Contains(filter.StudyProgramme.ToUpperInvariant()) ?? false);
            }

            if (filter.HasHourForInd.HasValue)
            {
                result = result.Where(s => s.HasHourForInd == filter.HasHourForInd.Value);
            }

            if (filter.HasHourForLecture.HasValue)
            {
                result = result.Where(s => s.HasHourForLecture == filter.HasHourForLecture.Value);
            }

            if (filter.HasHourForKoll.HasValue)
            {
                result = result.Where(s => s.HasHourForKoll == filter.HasHourForKoll.Value);
            }

            if (filter.HasHourForLecture.HasValue)
            {
                result = result.Where(s => s.HasHourForLecture == filter.HasHourForLecture.Value);
            }

            if (filter.HasHourForLab.HasValue)
            {
                result = result.Where(s => s.HasHourForLab == filter.HasHourForLab.Value);
            }

            if (filter.HasHourForPract.HasValue)
            {
                result = result.Where(s => s.HasHourForPract == filter.HasHourForPract.Value);
            }

            return(result.ToList());
        }