Example #1
0
        public IActionResult SendSMS([FromBody] SMSConfigurationViewModel emvm)
        {
            //string SmtpUrl = "smtp.office365.com";
            //string SmtpUN = "*****@*****.**";
            //string SmtpPwd = "SKF@4321";
            //string SenderEmailId = "*****@*****.**";
            //int Port = 25;
            //bool EnableSsl = true;

            string SMSMobileNo = emvm.AlarmSMSNotificationID;
            string strmessage  = emvm.AdditionalSMSID;
            //SmtpClient sc = new SmtpClient(SmtpUrl);
            //etworkCredential nc = new NetworkCredential(SmtpUN, SmtpPwd);
            string          strUrl     = "http://api.mVaayoo.com/mvaayooapi/[email protected]:Znod@12613&senderID=TEST SMS&receipientno=" + SMSMobileNo + "&msgtxt='" + strmessage + "'";
            WebRequest      request    = HttpWebRequest.Create(strUrl);
            HttpWebResponse response   = (HttpWebResponse)request.GetResponse();
            Stream          s          = (Stream)response.GetResponseStream();
            StreamReader    readStream = new StreamReader(s);
            string          dataString = readStream.ReadToEnd();

            response.Close();
            s.Close();
            readStream.Close();
            return(Ok("Success"));
        }
        public async Task <IEnumerable <dynamic> > SaveOrUpdate([FromBody] SMSConfigurationViewModel sv)
        {
            string sql = "dbo.EAppSaveAlarmSMSNotificationSetup";

            using (var conn = util.MasterCon())
            {
                try
                {
                    string AlarmSMSNotificationEquipmentsJson = null;
                    // string AlarmSMSNotificationServicesJson = null;
                    if (sv.AlarmSMSNotificationEquipments != null && sv.AlarmSMSNotificationEquipments.Count > 0)
                    {
                        string Header = "{\"AlarmSMSNotificationEquipments\": ";
                        string Footer = "}";
                        AlarmSMSNotificationEquipmentsJson = Header + JsonConvert.SerializeObject(sv.AlarmSMSNotificationEquipments) + Footer;
                    }

                    //if (sv.AlarmSMSNotificationServices != null && sv.AlarmSMSNotificationServices.Count > 0)
                    //{
                    //    string Header = "{\"AlarmSMSNotificationServices\": ";
                    //    string Footer = "}";
                    //    AlarmSMSNotificationServicesJson = Header + JsonConvert.SerializeObject(sv.AlarmSMSNotificationServices) + Footer;
                    //}

                    return(await(conn.QueryAsync <dynamic>(sql, new
                    {
                        sv.AlarmSMSNotificationSetupId,
                        sv.ClientSiteId,
                        sv.AlarmSMSNotificationID,
                        sv.IntervalDays,
                        sv.AdditionalSMSID,
                        AlarmSMSNotificationEquipmentsJson,
                        // AlarmSMSNotificationServicesJson,
                        sv.StatusId,
                        sv.UserId,
                        //sv.ProgramTypeId
                    }, commandType: CommandType.StoredProcedure)));
                }
                catch (SqlException sqlException)
                {
                    if (sqlException.Number == 2601 || sqlException.Number == 2627)
                    {
                        throw new CustomException("Duplicate", "AlarmSMSNotification Name already Exists.", "Error", true, sqlException);
                    }
                    else
                    {
                        throw new CustomException("Due to some Technical Reason, Unable to Save or Update", "Error", true, sqlException);
                    }
                }
                catch (Exception ex)
                {
                    throw new CustomException("Unable to Save Or Update, Please Contact Support!!!", "Error", true, ex);
                }
            }
        }
Example #3
0
        public async Task <IActionResult> Update([FromBody] SMSConfigurationViewModel sscv)
        {
            try
            {
                CurrentUser cUser = new CurrentUser(HttpContext, _configuration);
                sscv.UserId = cUser.UserId;
                var result = await SMSConfigurationRepo.SaveOrUpdate(sscv);

                await auditLogService.LogActivity(cUser.UserId, cUser.HostIP, cUser.SessionId, "SMSConfiguration", "SMSConfiguration Modified.");

                return(Ok(result));
            }
            catch (CustomException cex)
            {
                var returnObj = new EmaintenanceMessage(cex.Message, cex.Type, cex.IsException, cex.Exception?.ToString());
                return(StatusCode(StatusCodes.Status500InternalServerError, returnObj));
            }
            catch (Exception ex)
            {
                return(StatusCode(StatusCodes.Status500InternalServerError, new EmaintenanceMessage(ex.Message)));
            }
        }