Exemplo n.º 1
0
 public void DeleteChannelConversation(string username, long channelId)
 {
     try
     {
         using (ChatAppDBEntities context = new ChatAppDBEntities())
         {
             context.DeleteChannelUserMessages(channelId, username);
         }
     }
     catch (Exception exception)
     {
         //
     }
 }
Exemplo n.º 2
0
 public void DeleteMessage(string username, long messageId)
 {
     try
     {
         using (ChatAppDBEntities context = new ChatAppDBEntities())
         {
             context.DeleteMessage(username, messageId);
         }
     }
     catch (Exception exception)
     {
         //
     }
 }
Exemplo n.º 3
0
 public void DeleteUserConversation(string username, string usernameOther)
 {
     try
     {
         using (ChatAppDBEntities context = new ChatAppDBEntities())
         {
             context.DeleteUserMessages(username, usernameOther);
         }
     }
     catch (Exception exception)
     {
         //
     }
 }
Exemplo n.º 4
0
 public void EditMessage(string username, long messageId, string content)
 {
     try
     {
         using (ChatAppDBEntities context = new ChatAppDBEntities())
         {
             context.UpdateMessage(username, messageId, content);
         }
     }
     catch (Exception exception)
     {
         //
     }
 }
Exemplo n.º 5
0
 public long StoreUserMessage(string username, string usernameOther, string userMessage, DateTime timeSent)
 {
     try
     {
         using (ChatAppDBEntities context = new ChatAppDBEntities())
         {
             return(context.StoreUserMessage(userMessage, username, usernameOther, timeSent).FirstOrDefault() ?? 0);
         }
     }
     catch (Exception exception)
     {
         return(0L);
     }
 }
Exemplo n.º 6
0
 public List <MessageVM> GetChannelMessages(long channelId)
 {
     try
     {
         using (ChatAppDBEntities context = new ChatAppDBEntities())
         {
             var listMessages = context.GetChannelMessages(channelId, 100).ToList();
             return(getMessageVMs(listMessages));
         }
     }
     catch (Exception exception)
     {
         return(new List <MessageVM>());
     }
 }
Exemplo n.º 7
0
 public List <UserVM> GetChannelMembers(long channelId)
 {
     try
     {
         using (ChatAppDBEntities context = new ChatAppDBEntities())
         {
             var membersList = context.GetChannelMembers(channelId).ToList();
             return(getUserVMs(membersList));
         }
     }
     catch (Exception exception)
     {
         return(new List <UserVM>());
     }
 }
Exemplo n.º 8
0
 public List <UserVM> GetAllUsers()
 {
     try
     {
         using (ChatAppDBEntities context = new ChatAppDBEntities())
         {
             var listUsers = context.AllUsers().ToList();
             return(getUserVMs(listUsers));
         }
     }
     catch (Exception exception)
     {
         return(new List <UserVM>());
     }
 }
Exemplo n.º 9
0
 public List <MessageVM> GetDirectMessages(string username, string usernameOther)
 {
     try
     {
         using (ChatAppDBEntities context = new ChatAppDBEntities())
         {
             var listMessages = context.DirectMessages(username, usernameOther, 100).ToList();
             return(getMessageVMs(listMessages));
         }
     }
     catch (Exception exception)
     {
         return(new List <MessageVM>());
     }
 }
Exemplo n.º 10
0
        public void RegisterUser(User user)
        {
            try
            {
                using (ChatAppDBEntities context = new ChatAppDBEntities())
                {
                    context.RegisterUser(user.UserName, user.FirstName, user.LastName, user.Password, user.RegistrationDate);

                    //context.Users.Add(user);
                    //context.SaveChanges();
                }
            }
            catch (Exception exception)
            {
                //
            }
        }
Exemplo n.º 11
0
 public List <Channel> GetAllChannels()
 {
     try
     {
         using (ChatAppDBEntities context = new ChatAppDBEntities())
         {
             var            listChannels = context.AllChannels().ToList();
             List <Channel> allChannels  =
                 listChannels.Select(x => new Channel()
             {
                 ChannelId = x.ChannelId, ChannelName = x.ChannelName
             })
                 .ToList();
             return(allChannels);
         }
     }
     catch (Exception exception)
     {
         return(new List <Channel>());
     }
 }
Exemplo n.º 12
0
 public List <UserVM> GetUserMessageNotifications(string username, DateTime lastReceived)
 {
     try
     {
         using (ChatAppDBEntities context = new ChatAppDBEntities())
         {
             return
                 (context.GetUserMessageNotifications(username, lastReceived)
                  .ToList()
                  .Select(x => new UserVM()
             {
                 UserName = x
             })
                  .ToList());
         }
     }
     catch (Exception exception)
     {
         return(new List <UserVM>());
     }
 }