public void AddUser(string UserName) { if (UsersTable.FirstOrDefault(x => x.UserName == UserName) != null) { return; } UsersTable.Add(new User() { UserName = UserName }); SaveChanges(); }
public void AddMessage(string UserName, string MessageText) { var _user = UsersTable.FirstOrDefault(x => x.UserName.ToLower() == UserName.ToLower()); if (_user != null) { MessageTable.Add(new Message() { Text = MessageText, user = _user }); AddToHistory(new UserMessage() { Message = MessageText, UserName = _user.UserName }, false); SaveChanges(); } }