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); } }