Exemplo n.º 1
0
        public IActionResult GetMine([FromBody] PagerFilterSimpleModel model)
        {
            if (model == null)
            {
                _logger.LogWarning("ProfileController|GetMine|Invalid model.");
                return(BadRequest("Profile|GetMine|Invalid model"));
            }

            var userId = new UserToken {
                UserId = User.GetUserID()
            };

            if (string.IsNullOrEmpty(model.Query))
            {
                return(Ok(_dal.Where(s => !s.StandardProfileID.HasValue /*&& s.AuthorId.HasValue && s.AuthorId.Value.Equals(userId)*/,
                                     userId, model.Skip, model.Take, true)));
            }

            model.Query = model.Query.ToLower();
            var result = _dal.Where(s =>
                                    !s.StandardProfileID.HasValue && /*s.AuthorId.HasValue && s.AuthorId.Value.Equals(userId) &&*/
                                                                     //string query section
                                    (s.Namespace.ToLower().Contains(model.Query)
                                                                     //|| (s.Author != null && (s.Author.FirstName.ToLower() + s.Author.LastName.ToLower()).Contains(
                                                                     //    model.Query.Replace(" ", "").Replace("-", ""))) ||  //in case they search for code and name in one string.
                                    ),
                                    userId, model.Skip, model.Take, true);

            return(Ok(result));
        }
Exemplo n.º 2
0
        public IActionResult Search([FromBody] PagerFilterSimpleModel model)
        {
            if (model == null)
            {
                return(BadRequest("User|Search|Invalid model"));
            }

            var userToken = UserExtension.DalUserToken(User);

            if (string.IsNullOrEmpty(model.Query))
            {
                return(Ok(_dal.GetAllPaged(userToken, model.Skip, model.Take, true)));
            }

            model.Query = model.Query.ToLower();
            var result = _dal.Where(s =>
                                    //string query section
                                    //s.IsActive &&
                                    (s.UserName.ToLower().Contains(model.Query) ||
                                     (s.FirstName.ToLower() + s.LastName.ToLower()).Contains(
                                         model.Query.Replace(" ", "").Replace("-", ""))), //in case they search for code and name in one string.
                                    userToken, model.Skip, model.Take, true);

            return(Ok(result));
        }
Exemplo n.º 3
0
        public IActionResult GetLibrary([FromBody] PagerFilterSimpleModel model)
        {
            if (model == null)
            {
                _logger.LogWarning("ProfileController|GetLibrary|Invalid model");
                return(BadRequest("Profile|Library|Invalid model"));
            }

            //NEW - return all items. The list is small so return both standard, referenced and mine in one list.
            var userId = new UserToken {
                UserId = User.GetUserID()
            };

            if (string.IsNullOrEmpty(model.Query))
            {
                return(Ok(_dal.GetAllPaged(userId, model.Skip, model.Take, true)));
                //return Ok(_dal.Where(s => s.StandardProfileID.HasValue, // && (!s.AuthorId.HasValue || s.AuthorId.Value.Equals(userId)),
                //                userId, model.Skip, model.Take, true));
            }

            //search on some pre-determined fields
            model.Query = model.Query.ToLower();
            //var result = _dal.Where(s => s.StandardProfileID.HasValue && (!s.AuthorId.HasValue || s.AuthorId.Value.Equals(userId)) &&
            var result = _dal.Where(s =>
                                    //string query section
                                    s.Namespace.ToLower().Contains(model.Query),
                                    userId, model.Skip, model.Take, true);

            return(Ok(result));
        }
Exemplo n.º 4
0
        public IActionResult GetMine([FromBody] PagerFilterSimpleModel model)
        {
            if (model == null)
            {
                _logger.LogWarning("ImportLogController|GetMine|Invalid model.");
                return(BadRequest("Profile|GetMine|Invalid model"));
            }

            var userToken = new UserToken {
                UserId = User.GetUserID()
            };

            if (string.IsNullOrEmpty(model.Query))
            {
                return(Ok(_dal.GetAllPaged(userToken, model.Skip, model.Take, false, true)));
                //return Ok(_dal.Where(s => s.OwnerId.Equals(userId), userId, model.Skip, model.Take, true));
            }

            model.Query = model.Query.ToLower();
            var result = _dal.Where(s =>
                                    //s.OwnerId.Equals(userId) &&
                                    //string query section
                                    string.Join(",", s.FileList).ToLower().Contains(model.Query)
                                    , userToken, null, null, false, true);

            return(Ok(result));
        }