public HttpResponseMessage RegisterToken(ENT.UserDeviceToken modal) { GlobalVarible.Clear(); try { using (BAL.UserDeviceToken objBal = new BAL.UserDeviceToken()) { modal.udt_userid = _LOGINUSERID; modal.CreatedBy = _LOGINUSERID; modal.CreatedDateTime = DateTime.Now; if (objBal.Insert(modal)) { GlobalVarible.AddMessage("Token Registered Successfully."); return(ControllerContext.Request.CreateResponse(HttpStatusCode.OK, new { GlobalVarible.FormResult })); } else { GlobalVarible.AddError("Unable to Add Token.Please Try Again"); ERRORREPORTING.Report(new Exception("Unable to Add Token.Please Try Again"), _REQUESTURL, _LOGINUSERID, _ERRORKEY, new JavaScriptSerializer().Serialize(modal)); return(ControllerContext.Request.CreateResponse(HttpStatusCode.OK, new { GlobalVarible.FormResult })); } } } catch (Exception ex) { GlobalVarible.AddError(ex.Message); ERRORREPORTING.Report(ex, _REQUESTURL, _LOGINUSERID, _ERRORKEY, new JavaScriptSerializer().Serialize(modal)); return(ControllerContext.Request.CreateResponse(HttpStatusCode.OK, new { GlobalVarible.FormResult })); } }
public HttpResponseMessage SendNotification() { GlobalVarible.Clear(); using (BAL.UserDeviceToken objUDT = new BAL.UserDeviceToken()) { ENT.UserDeviceToken usertoken = objUDT.GetUserDeviceToken(Guid.Parse("5a5537fc-0411-45c1-8960-b24bbf1ea375")); if (usertoken != null) { string message = "Your account is credited with with 100. : " + DateTime.Now.Ticks.ToString(); FCMNOTIFICATION.SendPushNotification(usertoken.udt_devicetoken, message, Guid.Parse("5a5537fc-0411-45c1-8960-b24bbf1ea375"), 1); } } return(ControllerContext.Request.CreateResponse(HttpStatusCode.OK, new { GlobalVarible.FormResult })); }
public HttpResponseMessage doTransfer(doFundTransferModel data) { COM.DBHelper sqlhelper = new COM.DBHelper(); GlobalVarible.Clear(); List <string> strvalidationResult = new List <string>(); try { string token = _LOGINUSERID.ToString(); string reqdata = ENCDESC.Decrypt(data.data, token, data.userid); MDL.FundTransfer model = new FundTransfer(); model = new JavaScriptSerializer().Deserialize <MDL.FundTransfer>(reqdata); strvalidationResult = ValidateFundTransfer(model); if (strvalidationResult.Count() == 0) { if (checkpassword(model.up_password)) { model.up_upperid = Guid.Parse(User.Identity.GetUserId()); string[,] param = { { "PARENTID", model.up_upperid.ToString() }, { "USERID", model.up_userid.ToString() }, { "BALTOADD", model.up_fundbalance }, { "TRANSMODE", model.up_mode }, { "REMARKS", model.up_remakrs }, }; COM.DBHelper.SQLReturnValue M = sqlhelper.ExecuteProcWithMessageKMT("ADD_FUND_TO_ACCOUNT", param, true); if (M.ValueFromSQL == 1) { // get detail user device token using (BAL.UserDeviceToken objUDT = new BAL.UserDeviceToken()) { ENT.UserDeviceToken usertoken = objUDT.GetUserDeviceToken(model.up_userid); if (usertoken != null) { string message = "Your account is credited with with " + model.up_fundbalance.ToString(); FCMNOTIFICATION.SendPushNotification(usertoken.udt_devicetoken, message, model.up_userid, 1); } } GlobalVarible.AddMessage(M.MessageFromSQL); } else { throw new Exception(string.Join("<br />", M.MessageFromSQL)); } } else { throw new Exception(string.Join("<br />", "Invalid Password !")); } } else { throw new Exception(string.Join("<br />", strvalidationResult)); } return(ControllerContext.Request.CreateResponse(HttpStatusCode.OK, new { GlobalVarible.FormResult })); } catch (Exception ex) { GlobalVarible.AddError(ex.Message); ERRORREPORTING.Report(ex, _REQUESTURL, _LOGINUSERID, _ERRORKEY, string.Empty); return(ControllerContext.Request.CreateResponse(HttpStatusCode.OK, new { GlobalVarible.FormResult })); } }