//GET api/Passwords
        public IHttpActionResult Get()//get latest passwords preview
        {
            string userId = User.Identity.GetUserId();
            //bring from db just the item preview for passwords
            IEnumerable <ItemPreview> passwords = EntireItems.GetAllPasswords(db, userId);;

            return(Ok(passwords.GroupItems()));
        }
Пример #2
0
        private IEnumerable <ItemPreview> GetAllItems()
        {
            string userId = User.Identity.GetUserId();
            //take passwords
            var items = EntireItems.GetAllPasswords(db, userId)
                        .Union
                            (EntireItems.GetAllWifis(db, userId))
                        .Union
                            (EntireItems.GetAllNotes(db, userId))
                        .Union
                            (EntireItems.GetAllPaymentCards(db, userId));

            //return them
            return(items);
        }
Пример #3
0
        private IEnumerable <ItemPreview> SearchItems(string searchString)
        {
            if (string.IsNullOrEmpty(searchString))
            {
                return(null);
            }
            //get current user id
            string userId = User.Identity.GetUserId();
            //get items from db
            var items = EntireItems.GetAllPasswords(db, userId)
                        .Where(s => s.Title.Contains(searchString))
                        .Union//take wifis
                            (EntireItems.GetAllWifis(db, userId))
                        .Where(s => s.Title.Contains(searchString))
                        .Union
                            (EntireItems.GetAllNotes(db, userId))
                        .Where(s => s.Title.Contains(searchString))
                        .Union
                            (EntireItems.GetAllPaymentCards(db, userId))
                        .Where(s => s.Title.Contains(searchString));

            //return them
            return(items);
        }