Esempio n. 1
0
        public IActionResult OnGet(string pin = null, string user = null)
        {
            UserName = HttpContext.Session.GetString("_guest");
            System.Console.WriteLine("User = "******"/Login", new { area = "Guest", returnUrl = "chat" });
                return(LocalRedirect(url));
            }
        }
Esempio n. 2
0
        public async Task <IActionResult> OnGetAsync()
        {
            HopeLineUser CurrentUser = await _userManager.GetUserAsync(User);

            if (CurrentUser != null)
            {
                if (CurrentUser.AccountType == DataAccess.Entities.Account.User || CurrentUser.AccountType == DataAccess.Entities.Account.Guest)
                {
                    isUser = true;
                }
                else
                {
                    isUser = false;
                }
            }
            else
            {
                isUser = true;
            }

            Topics = _commonResource.GetTopics().Select(t => new TopicViewModel
            {
                Id   = t.Id,
                Name = t.Name
            }).ToList();

            return(Page());
        }
Esempio n. 3
0
 public IActionResult Topics()
 {
     try {
         return(Ok(_commonResource.GetTopics()));
     } catch (System.Exception ex) {
         _logger.LogInformation("Unable to get Topics: {}", ex);
         return(NotFound());
     }
 }
Esempio n. 4
0
        public async Task GetTopics(string userId, bool isUser)
        {
            var room         = _messageService.GetRoomForUser(userId, isUser);
            var ids          = _messageService.GetTopics(room);
            var allTopics    = _commonResource.GetTopics();
            var topics       = new List <TopicModel>();
            var stringTopics = "";

            foreach (var id in ids)
            {
                var topic = allTopics.FirstOrDefault(t => t.Id == id);
                if (topic != null)
                {
                    topics.Add(topic);
                    stringTopics = stringTopics + " " + topic.Name;
                }
            }
            await Clients.Group(room).SendAsync("Topics", topics.Select(t => t.Name));

            await Clients.Caller.SendAsync("ReceiveMessage", "HopeLine", "You have selected the following Topics: " + stringTopics);
        }
        public IActionResult OnGet()
        {
            /*
             * if user is authenticated, check if user is a mentor
             *  if user is a mentor, redirect user to mentor profile page
             *  if user is not a mentor, user can access Instant Chat
             * if user is not authenticated
             *  user can access Instant Chat
             */
            var claim = User.Claims.FirstOrDefault(u => u.Type == "Account");
            var url   = Url.Page("/Index", new { area = "Mentor" });

            if (User.Identity.IsAuthenticated)
            {
                if (claim.Value == "Mentor")
                {
                    return(Redirect(url));
                }
                return(Page());
            }
            else
            {
                Topics = _commonResource.GetTopics().Select(t => new TopicViewModel
                {
                    Id          = t.Id,
                    Name        = t.Name,
                    Description = t.Description
                }).ToList();

                UserName = HttpContext.Session.GetString("_guest");
                if (UserName != null)
                {
                    HttpContext.Session.SetString("_guest", UserName);
                }
                else
                {
                    var name = "Guest" + Guid.NewGuid().ToString("N").Substring(0, 12);
                    UserName = name;
                    HttpContext.Session.SetString("_guest", UserName);
                }
                // Topics = _commonResource.GetTopics().Select(t => t.Name).ToList();
                return(Page());
            }
            //else
            //{
            //    return LocalRedirect(url);

            //}
        }
        public async Task <IActionResult> CreateTopics()
        {
            if (_commonResource.GetTopics().Count() == 0)
            {
                var topics = new List <TopicModel> {
                    //Populate topics
                    new TopicModel {
                        Name        = "Mental Disorder",
                        Description = "A mental disorder, also called a mental illness[2] or psychiatric disorder, is a behavioral or mental pattern that causes significant distress or impairment of personal functioning.[3] Such features may be persistent, relapsing and remitting, or occur as a single episode. Many disorders have been described, with signs and symptoms that vary widely between specific disorders.[4][5] Such disorders may be diagnosed by a mental health professional."
                    },
                    new TopicModel {
                        Name        = "Eating Disorder",
                        Description = "An eating disorder is a mental disorder defined by abnormal eating habits that negatively affect a person's physical or mental health.[1] They include binge eating disorder where people eat a large amount in a short period of time, anorexia nervosa where people eat very little and thus have a low body weight, bulimia nervosa where people eat a lot and then try to rid themselves of the food, pica where people eat non-food items, rumination disorder where people regurgitate food, avoidant/restrictive food intake disorder where people have a lack of interest in food, and a group of other specified feeding or eating disorders.[1] Anxiety disorders, depression, and substance abuse are common among people with eating disorders.[2] These disorders do not include obesity.[1]"
                    },
                    new TopicModel {
                        Name        = "Anxiety",
                        Description = "Anxiety is an emotion characterized by an unpleasant state of inner turmoil, often accompanied by nervous behaviour such as pacing back and forth, somatic complaints, and rumination.[1] It is the subjectively unpleasant feelings of dread over anticipated events, such as the feeling of imminent death.[2][need quotation to verify] Anxiety is not the same as fear, which is a response to a real or perceived immediate threat,[3] whereas anxiety involves the expectation of future threat.[3] Anxiety is a feeling of uneasiness and worry, usually generalized and unfocused as an overreaction to a situation that is only subjectively seen as menacing.[4] It is often accompanied by muscular tension,[3] restlessness, fatigue and problems in concentration. Anxiety can be appropriate, but when experienced regularly the individual may suffer from an anxiety disorder.[3]"
                    },
                    new TopicModel {
                        Name        = "Schizophrenia",
                        Description = "Schizophrenia is a mental disorder characterized by abnormal behavior and a decreased ability to understand reality.[2] Common symptoms include false beliefs, unclear or confused thinking, hearing voices that others do not, reduced social engagement and emotional expression, and a lack of motivation.[2][3] People with schizophrenia often have additional mental health problems such as anxiety, depressive, or substance-use disorders.[11] Symptoms typically come on gradually, begin in young adulthood, and in many cases never resolve.[3][5]"
                    },
                    new TopicModel {
                        Name        = "Bipolar Disorder",
                        Description = "Bipolar disorder, previously known as manic depression, is a mental disorder that causes periods of depression and periods of abnormally elevated mood.[3][4][6] The elevated mood is significant and is known as mania or hypomania, depending on its severity, or whether symptoms of psychosis are present.[3] During mania, an individual behaves or feels abnormally energetic, happy, or irritable.[3] Individuals often make poorly thought out decisions with little regard to the consequences.[4] The need for sleep is usually reduced during manic phases.[4] During periods of depression, there may be crying, a negative outlook on life, and poor eye contact with others.[3] The risk of suicide among those with the illness is high at greater than 6 percent over 20 years, while self-harm occurs in 30�C40 percent.[3] Other mental health issues such as anxiety disorders and substance use disorder are commonly associated with bipolar disorder.[3]"
                    },
                    new TopicModel {
                        Name        = "Mood Disorder",
                        Description = "Mood disorder, also known as mood (affective) disorders, is a group of conditions where a disturbance in the person's mood is the main underlying feature.[1] The classification is in the Diagnostic and Statistical Manual of Mental Disorders (DSM) and International Classification of Diseases (ICD)."
                    },
                    new TopicModel {
                        Name        = "Depression",
                        Description = "Depression, a state of low mood and aversion to activity, can affect a person's thoughts, behavior, tendencies, feelings, and sense of well-being. A depressed mood is a normal temporary reaction to life events - such as loss of a loved one. It is also a symptom of some physical diseases and a side effect of some drugs and medical treatments. Depressed mood may also be a symptom of some mood disorders such as major depressive disorder or dysthymia.[2]"
                    }
                };

                foreach (var item in topics)
                {
                    _commonResource.AddTopics(item);
                }
                await _commonResource.SaveTopicAsync();

                return(Ok("Data Newly Populated"));
            }
            return(Ok("Already populated"));
        }
Esempio n. 7
0
        public void AddTopicsToRoom(string roomId, IList <int> topics)
        {
            var room      = _chatDb.Rooms.SingleOrDefault(r => r.RoomId == roomId);
            var list      = new List <TopicModel>();
            var allTopics = _commonResource.GetTopics();

            foreach (var id in topics)
            {
                var topic = allTopics.FirstOrDefault(t => t.Id == id);
                if (topic != null)
                {
                    room.Topics.Add(new Topic
                    {
                        Id          = topic.Id,
                        Name        = topic.Name,
                        Description = topic.Description
                    });
                }
            }
            _chatDb.Update(room);
            _chatDb.SaveChanges();
        }