Пример #1
0
 public IEnumerable<UserPosition> FindUserPositions(UserPositionsSearchCriteria searchCriteria)
 {
     return Repository.List<UserPosition>(searchCriteria.BuildCriteria());
 }
        public ActionResult Position(GridOptionsModel options)
        {
            if(!options.id.HasValue)
            {
                DisplayError("No position specified.");
                return View(new PositionViewModel {Data = new List<UserPositionModel>().AsPagination(options.Page, 10), Position = new PositionModel()});
            }

            var searchCriteria = new UserPositionsSearchCriteria
                                     {
                                         Ascending = options.Ascending,
                                         DistinctRootEntity = true,
                                         OrderByProperty = options.Column,
                                         Positions = new[] {options.id.Value}
                                     };
            var userPositions = _positionService.FindUserPositions(searchCriteria);
            var model = new PositionViewModel
                            {
                                Position = Mapper.Map<Position, PositionModel>(!userPositions.Any()
                                                                            ? _positionService.GetPosition(options.id.Value)
                                                                            : userPositions.First().Position),
                                Data = Mapper.Map<IEnumerable<UserPosition>, IEnumerable<UserPositionModel>>(userPositions).AsPagination(options.Page, 10)
                            };

            return View(model);
        }