Esempio n. 1
0
        public async Task <ActionResult <IEnumerable <User> > > Query([FromQuery] _basisParameters qparams)
        {
            var    canAccess      = Helpers.AuthenticationHelper.canAccessUserData(HttpContext.User);
            var    claimsIdentity = HttpContext.User.Identity as ClaimsIdentity;
            string username       = claimsIdentity.Claims.FirstOrDefault(x => x.Type == ClaimTypes.Name)?.Value;

            var users = await _context.Users.Where(x => !String.IsNullOrEmpty(username) && x.UserName == username).AsNoTracking().ToListAsync();

            // Filter the request as per the query parameters
            return(users);
        }
Esempio n. 2
0
        public async Task <ActionResult <MessagesResponse> > ByUserID([FromRoute] Guid user_id, [FromQuery] _basisParameters qparams)
        {
            var    canAccess      = Helpers.AuthenticationHelper.canAccessUserData(HttpContext.User);
            var    claimsIdentity = HttpContext.User.Identity as ClaimsIdentity;
            string username       = claimsIdentity.Claims.FirstOrDefault(x => x.Type == ClaimTypes.Name)?.Value;
            string userGID        = user_id.ToString();

            if (!canAccess)
            {
                canAccess = _context.Users.Any(x => !String.IsNullOrEmpty(username) && x.UserName == username && x.UserGID == userGID);
            }

            if (canAccess)
            {
                // Get the messages associated with this userGID
                var messageCount       = _context.Messages.Count(x => x.MessageRecipients.Any(y => y.UserGID == userGID));
                var unreadMessageCount = _context.Messages.Count(x => x.MessageRecipients.Any(y => y.UserGID == userGID && !y.MessageRead));

                var messages = await _context.Messages.Where(x => x.MessageRecipients.Any(y => y.UserGID == userGID)).Take(20).AsNoTracking().ToListAsync();

                // Send the response back
                return(new MessagesResponse
                {
                    Count = messageCount,
                    UnreadCount = unreadMessageCount,
                    Messages = messages
                });
            }

            // If the user is unknown, reply with an error
            return(GenericError.create(this, StatusCodes.Status401Unauthorized,
                                       "You do not have access to this user's messages"));
        }
        public async Task <ActionResult <Content> > Query([FromRoute] int dependency_id, [FromQuery] _basisParameters qparams)
        {
            Content content = new Content();

            // Filter the request as per the query parameters
            if (dependency_id == 1)
            {
                content.Id    = 1;
                content.Title = "Welcome to our \"Live Well\" community";
                content.Title = "Our vision is to use an integrated approach to address our population's health and wellness. The Healthy Life Course approach works toward building lasting, improved health and wellness for our people. We support our community based on this approach, which suggests that the health and wellness outcomes of individuals, families, and communities depend on many variables, including universality, equity and community health variables. These can include things that can improve our wellbeing (protective factors) and things that can worsen it (risk factors) throughout life. The model also provides for a broader understanding of the population's health and health service delivery, which is key in pursuing universal health for the current and future populations of the Region.You are welcome to join our \"Live Well\" initiative!";
                content.Image = "/static/images/PopulationHealthAndWellness_Gray.png";
            }

            return(content);
        }