Exemplo n.º 1
0
        public async Task <IActionResult> ForLogged(string name, string email)
        {
            User user = repos.GetUserOnEmail(email);
            Chat chat = repos1.GetChatOnName(name);

            return(RedirectToAction("Chat", "Chat", new { chat.GUID }));
        }
Exemplo n.º 2
0
        public async Task <IActionResult> Create(CreateModel model)
        {
            ViewBag.Admin = false;
            if (this.User.FindFirstValue(ClaimTypes.Role) == "Admin")
            {
                ViewBag.Admin = true;
            }
            Chat chat = repos1.GetChatOnName(model.Name);

            if (chat != null)
            {
                string        email = model.Email;
                User          user  = repos.GetUserOnEmail(email);
                List <Chat>   chats = repos.GetChats(user.UserId);
                List <string> names = new List <string>();
                foreach (Chat chat1 in chats)
                {
                    names.Add(chat1.Name);
                }
                ViewBag.Chats = names;
                ViewBag.Email = email;
                ViewBag.Error = "Чат с данным именем существует";
                return(View("Index"));
            }
            repos1.Create(new Chat {
                Name = model.Name, GUID = Guid.NewGuid().ToString()
            }, model.Email);
            return(RedirectToAction("Index", "Home"));
        }