public bool RemoveUserFromChat(User user, Chat chat) { try { List <User> usersOfChat = GetUsersOfChat(chat); if (usersOfChat.Count == 1) { RemoveChat(chat); } else { using (var context = new TitanNetworkContext()) { Room room = context.Rooms.FirstOrDefault(g => g.UserId == user.Id && g.ChatId == chat.Id); context.Entry(room).State = EntityState.Deleted; context.SaveChanges(); } } return(true); } catch { return(false); } }
public bool AddMessageLog(MessageLog log) { try { using (var context = new TitanNetworkContext()) { context.Entry(log).State = EntityState.Added; context.SaveChanges(); return(true); } } catch { return(false); } }
public bool AddBotCache(BotCache cache) { try { using (var context = new TitanNetworkContext()) { context.Entry(cache).State = EntityState.Added; context.SaveChanges(); return(true); } } catch { return(false); } }
public bool UpdateMessage(Message message) { try { using (var context = new TitanNetworkContext()) { context.Entry(message).State = EntityState.Modified; context.SaveChanges(); return(true); } } catch { return(false); } }
public bool RemoveChat(Chat chat) { try { using (var context = new TitanNetworkContext()) { context.Entry(chat).State = EntityState.Deleted; context.SaveChanges(); return(true); } } catch { return(false); } }
public bool AddUserToChat(User user, Chat chat) { try { using (var context = new TitanNetworkContext()) { Room room = new Room(); room.UserId = user.Id; room.ChatId = chat.Id; context.Rooms.Add(room); context.SaveChanges(); return(true); } } catch { return(false); } }