public ResponseMessage SendMessage(UserToVendorMessage newMessage)
        {
            string          reply = string.Empty;
            ResponseMessage rM    = new ResponseMessage();

            try
            {
                var result = apiRepository.SaveMessage(newMessage, ref reply);
                if (result[0] == "Y")
                {
                    rM.MessageCode   = "Y";
                    rM.Message       = result[1];
                    rM.SystemMessage = reply;
                    rM.Content       = "Message sent successfully.";
                }
                else
                {
                    rM.MessageCode   = "N";
                    rM.Message       = result[1];
                    rM.SystemMessage = reply;
                    rM.Content       = result[1];
                }
            }
            catch (Exception ex)
            {
                rM.MessageCode   = "N";
                rM.Message       = "System Error";
                rM.SystemMessage = ex.Message;
                rM.Content       = "Failed to send message due to server problem.";
                return(rM);
            }


            return(rM);
        }
Esempio n. 2
0
        public string[] SaveMessage(UserToVendorMessage newMessage, ref string replay)
        {
            string[] res = new string[4];

            string msg_code = string.Empty;
            string msg      = string.Empty;

            try
            {
                objSqlProcManager = new SqlProcedureManager(connectionString);
                string spname = "sp_Save_a_Message";

                var result = objSqlProcManager.ExecuteNonQuery(spname, ref replay,
                                                               newMessage.SenderId,
                                                               newMessage.ReceiverId,
                                                               newMessage.MessageDetails,
                                                               "",
                                                               "Y"
                                                               );

                if (result > 0)
                {
                    res[0] = "Y";
                    res[1] = "Message sent.";
                }
                else
                {
                    res[0] = "N";
                    res[1] = "Failed to send message.";
                }

                //  string decryptedPassword = objEncrypt.DecryptString(encryptedPassword, "");

                return(res);
            }
            catch (Exception errorException)
            {
                throw errorException;
            }
            return(res);
        }