protected void btnAddChange_Click(object sender, EventArgs e) { List <int> membersList = new List <int>(); foreach (GridViewRow row in gvMembersOfCommittee.Rows) { int member = Convert.ToInt32(row.Cells[1].Text); membersList.Add(member); } string apiUrl2 = Utilities.BASE_URL + "/api/CommitteesMembers"; int memberId = WebApiConsume.GetUserId(Utilities.BASE_URL + "/api/Users", ddlMemberChange.SelectedItem.Text); if (!membersList.Contains(memberId)) { int?meetingId = WebApiConsume.GetMeetingId(Utilities.BASE_URL + "/api/Committees", Convert.ToInt32(ViewState["CommitteeId"]), ViewState["CreatedAt"].ToString()); CommitteesMember input = new CommitteesMember { CommitteeId = Convert.ToInt32(ViewState["CommitteeId"]), MemberId = memberId, CommitteeRole = 6, UpdatedAt = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), CreatedAt = ViewState["CreatedAt"].ToString(), MeetingId = meetingId }; try { string apiUrlUser = Utilities.BASE_URL + "/api/Users"; string inputJson3 = (new JavaScriptSerializer()).Serialize(input); WebApiConsume.PostCommitteeMembersUpdate(Utilities.BASE_URL + "/api/CommitteesMembers", inputJson3); gvMembersOfCommittee.DataSource = WebApiConsume.ShowCommitteeMembers(Convert.ToInt32(ViewState["CommitteeId"])); gvMembersOfCommittee.DataBind(); User userFcm = WebApiConsume.GetUserById(Utilities.BASE_URL + "/api/Users", memberId); string apiUrlFcm = Utilities.BASE_URL + "/api/Fcm"; WebApiConsume.SendUserNotification(apiUrlFcm, Convert.ToInt32(ViewState["CommitteeId"]), txtCommitteeName.Text, userFcm.FCMToken); SMS.SendSms("انت عضو فى لجنة " + "\n" + txtCommitteeName.Text + " المشكلة بتاريخ " + "\n" + txtCommitteeDate.Text, userFcm.Phone); foreach (GridViewRow row in gvMembersOfCommittee.Rows) { string mobile = row.Cells[3].Text; SMS.SendSms("تم اضافة عضو للجنة " + "\n" + txtCommitteeName.Text + " المشكلة بتاريخ " + "\n" + txtCommitteeDate.Text, mobile); } // Utilities.SendMailToOnePerson(userFcm.UserEmailId, "انضمام للجنة", "تم اضافتك للجنة بنجاح"); ScriptManager.RegisterClientScriptBlock(this.Page, this.Page.GetType(), "تم", "alert('تم اضافة العضو لللجنة بنجاح');", true); } catch (Exception ex) { string filePath = @Utilities.LogError_Path + "Error.txt"; using (StreamWriter writer = new StreamWriter(filePath, true)) { writer.WriteLine("-----------------------------------------------------------------------------"); writer.WriteLine("Date : " + DateTime.Now.ToString()); writer.WriteLine(); while (ex != null) { writer.WriteLine(ex.GetType().FullName); writer.WriteLine("Message : " + ex.Message); writer.WriteLine("StackTrace : " + ex.StackTrace); ex = ex.InnerException; } } } //Page.ClientScript.RegisterStartupScript(this.GetType(), "toastr_message", "toastr.success('تم ارسال الاشعارات بنجاح', 'تم')", true); } else { Page.ClientScript.RegisterStartupScript(this.GetType(), "toastr_message", "toastr.error('هذا العضو موجود بالفعل داخل اللجنه', 'تحذير')", true); //ScriptManager.RegisterClientScriptBlock(this.Page, this.Page.GetType(), "تحذير", "alert('هذا العضو موجود بالفعل داخل اللجنه');", true); } }