Exemple #1
0
        internal static int CheckPhoneId(string phoneNumber, String clientName, String email)
        {
            ChatUserBE wChatUserBE = GetChatUser(phoneNumber, clientName);

            if (wChatUserBE != null)
            {
                return(wChatUserBE.ChatUserId);
            }

            wChatUserBE = new ChatUserBE();
            /// Si no existe lo crea
            wChatUserBE.ChatUserPhone = phoneNumber;
            wChatUserBE.ChatUserName  = clientName;
            wChatUserBE.ChatUserEmail = email;

            ChatUserDAC.Insert(wChatUserBE);

            return(wChatUserBE.ChatUserId);
        }
Exemple #2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="phone"></param>
        /// <param name="clientName"></param>
        /// <returns></returns>
        static ChatUserBE GetChatUser(string phoneNumber, String clientName)
        {
            bool needUpdate = false;
            //String id = String.Concat(clientName, "$", phone);
            ChatUserBE userBE = ChatUserDAC.GetByParams(phoneNumber);


            if (userBE != null)
            {
                //Si esta en null directamtente le seteamos el clientName (este caso no deberia existir pero fisicamente es posible)
                //if (String.IsNullOrEmpty(userBE.ChatUserPhone))
                //{
                //    userBE.ChatUserPhone = phoneNumber;
                //    needUpdate = true;
                //}
                //Actualiza el nombre del cliente si es necesario
                if (!String.IsNullOrEmpty(clientName))
                {
                    if (userBE.ChatUserName.Trim().CompareTo(clientName.Trim()) != 0)
                    {
                        userBE.ChatUserName = clientName;
                        needUpdate          = true;
                    }
                }

                if (needUpdate)
                {
                    ChatUserDAC.Update(userBE);
                }

                return(userBE);
            }
            else
            {
                return(null);
            }
        }
 public static ChatUserBE GetChatUserByParams(int?pChatUserId, string pClientPhone)
 {
     return(ChatUserDAC.GetByParams(pClientPhone));
 }