Exemplo n.º 1
0
        public List <msg_conv> GetconvListByUserName(string username, int userId)
        {
            using (var context = new IgorMarkivMessengerDBEntities())
            {
                List <Users>    usersList = context.Users.Where(usr => usr.userName == username).ToList();
                List <msg_conv> Emptyconv = new List <msg_conv>();

                if (usersList.Count == 0)
                {
                    return(Emptyconv);
                }
                else
                {
                    int             tergetUserId = usersList[0].id;
                    List <msg_conv> convList     = context.msg_conv.Where(conv => (conv.user1 == tergetUserId && conv.user2 == userId) || (conv.user1 == userId && conv.user2 == tergetUserId)).ToList();

                    if (convList.Count == 0)
                    {
                        msg_conv conv = CreateConversation(userId, usersList[0].id);
                        convList.Add(conv);
                        return(convList);
                    }
                    else
                    {
                        return(convList);
                    }
                }
            }
        }
Exemplo n.º 2
0
 public msg_conv GetConversationByConversationId(int converationId)
 {
     using (var context = new IgorMarkivMessengerDBEntities())
     {
         msg_conv msg_Conv = context.msg_conv.Where(mc => mc.id == converationId).FirstOrDefault();
         return(msg_Conv);
     }
 }
Exemplo n.º 3
0
 public static msg_conv CreateConversation(int user1, int user2)
 {
     using (var context = new IgorMarkivMessengerDBEntities())
     {
         msg_conv conv = new msg_conv()
         {
             user1 = user1, user2 = user2
         };
         context.msg_conv.Add(conv);
         context.SaveChanges();
         return(conv);
     }
 }
 public static msg_conv GetConversationByConversationId(int conversationId)
 {
     try
     { return(_DB.GetConversationByConversationId(conversationId)); }
     catch (Exception ex)
     {
         LogManager.LogError("MessangerHelper GetConversationByConversationId", ex.Message, "Temporary Empty");
         msg_conv msg_Conv = new msg_conv()
         {
             id = -1
         };
         return(msg_Conv);
     }
 }
Exemplo n.º 5
0
 public bool CheckConversationUser(int userId, int convId)
 {
     using (var context = new IgorMarkivMessengerDBEntities())
     {
         msg_conv conv = context.msg_conv.Where(cv => cv.id == convId).FirstOrDefault();
         if (conv.user1 == userId)
         {
             return(true);
         }
         else
         {
             return(false);
         }
     }
 }