public string GetAllMessages(string username, string chatUser)
        {
            JSonResult result = new JSonResult();
            result.Status = false;

            List<GetMessages> allMessages = new List<GetMessages>();
            Chat chat = new Chat();
            Users user = new Users();

            Guid guid;
            user.GetUserGuid(username, out guid);
            Guid chatUserGuid;
            user.GetUserGuid(chatUser, out chatUserGuid);
            DataSet ds = chat.GetAllMessages(guid, chatUserGuid);
            foreach (DataRow dr in ds.Tables[0].Rows)
            {
                GetMessages message = new GetMessages();
                message.FromUser = dr["FromUser"].ToString();
                message.Message = dr["Comment"].ToString();
                message.Time = dr["ChatingTime"].ToString();

                allMessages.Add(message);
            }

            result.Status = true;
            JavaScriptSerializer serializer = new JavaScriptSerializer();
            string jsonresult = serializer.Serialize(allMessages);

            return jsonresult;
        }
        public string SendMessage(string fromUser, string toUser, string message)
        {
            JSonResult result = new JSonResult();
            result.Status = false;

            Users obj = new Users();
            Guid fromUserId, toUserId;
            obj.GetUserGuid(toUser, out toUserId);
            obj.GetUserGuid(fromUser, out fromUserId);

            Chat chat = new Chat();
            result.Status = chat.SendMessage(fromUserId, toUserId, message);

            JavaScriptSerializer serializer = new JavaScriptSerializer();
            string jsonresult = serializer.Serialize(result.Status);

            return jsonresult;
        }
        public string SignUpUser(string username, string password)
        {
            //CreateNewContent("MacroContent1", "");
            //CreateNewContent("MicroContent1", "MacroContent1");
            //CreateNewContent("MicroContent2", "MacroContent1");
            //CreateNewContent("MicroContent3", "MacroContent1");
            //CreateNewContent("MacroContent2", "");
            //CreateNewContent("MicroContent1", "MacroContent2");
            //CreateNewContent("MicroContent2", "MacroContent2");
            //CreateNewContent("MicroContent3", "MacroContent2");

            //GetAllContent();

            JSonResult result = new JSonResult();
            result.Status = false;

            Users obj = new Users();

            bool isUserValid = obj.CheckUserAndPasswordValid(username, password);

            //bool userCreated = obj.CreateNewUser("KARTHIK", "KARTHIK");
            //bool userCreated1 = obj.CreateNewUser("DIVI", "DIVI");
            //bool userCreated2 = obj.CreateNewUser("BALA", "BALA");
            //bool userCreated3 = obj.CreateNewUser("SEETHA", "SEETHA");
            //bool userCreated4 = obj.CreateNewUser("RAJNIKANTH", "RAJNIKANTH");
            //bool userCreated5 = obj.CreateNewUser("MICHAEL,SCHUMACKER", "MICHAEL,SCHUMACKER");
            //bool userCreated6 = obj.CreateNewUser("KAMALAHASAN", "KAMALAHASAN");
            //bool userCreated7 = obj.CreateNewUser("AJITH", "AJITH");
            //bool userCreated8 = obj.CreateNewUser("VIKRAM", "VIKRAM");
            //bool userCreated9 = obj.CreateNewUser("SURYA", "SURYA");
            //bool userCreated10 = obj.CreateNewUser("ARYA", "ARYA");
            //bool userCreated11 = obj.CreateNewUser("KOUNDAMANI", "KOUNDAMANI");
            //bool userCreated12 = obj.CreateNewUser("SENTHIL", "SENTHIL");
            //bool userCreated13 = obj.CreateNewUser("VADIVELU", "VADIVELU");
            //bool userCreated14 = obj.CreateNewUser("SANTHANAM", "SANTHANAM");

            //Guid karthikUserId,fromUserId1, fromUserId2;
            //obj.GetUserGuid("Karthik", out karthikUserId);
            //obj.GetUserGuid("BALA", out fromUserId1);
            //obj.GetUserGuid("DIVI", out fromUserId2);

            //Chat chat = new Chat();
            //chat.SendMessage(fromUserId1, karthikUserId, "Hi, Karthik");
            //chat.SendMessage(fromUserId1, karthikUserId, "How r u?");
            //chat.SendMessage(karthikUserId, fromUserId2, "Hi DIVI");
            //chat.SendMessage(fromUserId2, karthikUserId, "I am fine, dear.......");

            //DataSet ds1 = chat.GetAllOnlineUsers();
            //DataSet ds2 = chat.GetAllMessages(karthikUserId);

            Guid guid;
            obj.GetUserGuid(username, out guid);

            SignedInUser user = new SignedInUser();
            if (isUserValid)
            {
                user.SignedInUserId = guid.ToString();
                user.SignedInUserName = username;
                user.Status = "true";
            }
            else { user.Status = "false"; }

            result.Status = true;
            bool st = true;
            JavaScriptSerializer serializer = new JavaScriptSerializer();
            string jsonresult = serializer.Serialize(user);

            return jsonresult;
        }
        public string RegisterUser(string username, string password, string email)
        {
            JSonResult result = new JSonResult();
            result.Status = false;

            Users obj = new Users();
            bool userCreated = obj.CreateNewUser(username, password);

            Guid guid;
            obj.GetUserGuid(username, out guid);

            bool isUserValid = obj.CheckUserAndPasswordValid(username, password);

            SignedInUser user = new SignedInUser();
            if (isUserValid)
            {
                user.SignedInUserId = guid.ToString();
                user.SignedInUserName = username;
                user.Status = "true";
            }
            else { user.Status = "false"; }

            result.Status = true;
            bool st = true;
            JavaScriptSerializer serializer = new JavaScriptSerializer();
            string jsonresult = serializer.Serialize(user);

            return jsonresult;
        }