Пример #1
0
        public async Task <bool> AddChatContactAsync(int chatUserId, int contactUserId)
        {
            var contact = await _chatUserDbContext.UserContacts.Where(x => x.UserId == chatUserId && x.ContactUserId == contactUserId).SingleOrDefaultAsync();

            if (contact != null)
            {
                return(true);
            }

            _chatUserDbContext.UserContacts.Add(new UserContact
            {
                UserId        = chatUserId,
                ContactUserId = contactUserId
            });
            return(_chatUserDbContext.SaveChanges() > 0);
        }
Пример #2
0
        public async Task <bool> UpdateChatStatusAsync(int chatUserId, string status)
        {
            var user = await _chatUserDbContext.ChatUsers.Where(x => x.ChatUserId == chatUserId).SingleOrDefaultAsync();

            if (user != null)
            {
                user.Status = status;
                _chatUserDbContext.ChatUsers.Attach(user);
                return(_chatUserDbContext.SaveChanges() > 0);
            }
            return(false);
        }