public ActionResult Register(RegisterModel model) { if (ModelState.IsValid) { var user = _chatRepository.GetUser(0, model.Name); if (user != null) { ModelState.AddModelError("", "A user with this name is already in the system"); return(View(model)); } // TODO: make submit application instead add to users user = new User { Name = model.Name, Password = model.Password, Role = "User", CanCreateRoom = true, CanWriteMessages = true }; _chatRepository.AddUser(user); return(RedirectToAction("Login", "Account")); } return(View(model)); }
public ChatModel NewUser(User user) { ChatModel model = new ChatModel(); if (_chatRepo.ActiveUserCount() >= MAX_USERS) { model.TooManyUsers = true; model.Messages = new List <Message>(); model.Users = new List <User>(); return(model); } _chatRepo.AddUser(ObjectTranslator.GetDbUser(user)); model.Messages = GetLatestMessages().ToList(); model.Users = GetActiveUsers().ToList(); return(model); }
public async Task <IActionResult> AddUser(Guid chatId, string userId) { await _chatRep.AddUser(chatId, userId); return(Ok()); }