Exemplo n.º 1
0
    public void Insert_tbl_SMS(tbl_SMS obj_tbl_SMS)
    {
        DataSet        set1     = new DataSet();
        SqlCommand     command1 = null;
        SqlDataAdapter adapter1 = null;
        string         strQuery = "";

        strQuery = " set dateformat dmy;insert into tbl_SMS (SMS_Mobile_No, SMS_Content, SMS_Response, SMS_AddedOn) values ('" + obj_tbl_SMS.SMS_Mobile_No + "', '" + obj_tbl_SMS.SMS_Content + "','" + obj_tbl_SMS.SMS_Response + "', getdate());Select @@Identity";
        try
        {
            using (SqlConnection con = new SqlConnection(ConStr))
            {
                command1 = new SqlCommand(strQuery, con);
                if (command1.Connection.State == ConnectionState.Closed)
                {
                    command1.Connection.Open();
                }
                command1.CommandTimeout = 7000;
                adapter1 = new SqlDataAdapter(command1);
                adapter1.Fill(set1);
            }
        }
        catch
        {
        }
    }
Exemplo n.º 2
0
 public async Task <ActionResult <tbl_SMS> > Post(tbl_SMS model)
 {
     try
     {
         return(await repository.Add(model));
     }
     catch (Exception)
     {
         return(NoContent());
     }
 }
Exemplo n.º 3
0
    public static void SendSMS(List <SMS_Objects> obj_SMS_Objects)
    {
        for (int i = 0; i < obj_SMS_Objects.Count; i++)
        {
            string MobileNum    = obj_SMS_Objects[i].MobileNum;
            string SMS_Content  = obj_SMS_Objects[i].SMS_Content;
            string SMS_Response = obj_SMS_Objects[i].SMS_Response;
            string Sid          = obj_SMS_Objects[i].Sid;
            string sms_URL      = "";

            if (Sid == "" || string.IsNullOrEmpty(Sid))
            {
                sms_URL = "http://prioritysms.tulsitainfotech.com/api/mt/SendSMS?user=urbandevelopment&password=urban&senderid=MASTER&channel=Trans&DCS=0&flashsms=0&number=" + MobileNum + "&text=" + SMS_Content + "&route=15";
            }
            else
            {
                sms_URL = "http://prioritysms.tulsitainfotech.com/api/mt/SendSMS?user=urbandevelopment&password=urban&senderid=" + Sid + "&channel=Trans&DCS=0&flashsms=0&number=" + MobileNum + "&text=" + SMS_Content + "&route=15";
            }

            try
            {
                WebRequest request;
                string     MobileNo = MobileNum.Trim();
                string     sms      = SMS_Content.Trim();
                request             = WebRequest.Create(sms_URL);
                request.Credentials = CredentialCache.DefaultCredentials;
                HttpWebResponse response1          = (HttpWebResponse)request.GetResponse();
                Stream          dataStream         = response1.GetResponseStream();
                StreamReader    reader             = new StreamReader(dataStream);
                String          responseFromServer = reader.ReadToEnd();
                SMS_Response = responseFromServer.ToString().Trim();

                tbl_SMS obj_SMS = new tbl_SMS();
                obj_SMS.SMS_Content   = sms;
                obj_SMS.SMS_Mobile_No = MobileNo;
                obj_SMS.SMS_Response  = SMS_Response;
                new DataLayer().Insert_tbl_SMS(obj_SMS);

                reader.Close();
                dataStream.Close();
                response1.Close();
            }
            catch
            {
                SMS_Response = "Error";
            }
        }
    }
Exemplo n.º 4
0
        public async Task <ActionResult <tbl_SMS> > Put(long id, tbl_SMS model)
        {
            if (id != model.Id)
            {
                return(BadRequest());
            }

            try
            {
                return(await repository.Update(model));
            }
            catch (DbUpdateConcurrencyException)
            {
                return(NoContent());
            }
        }