public IHttpActionResult ViewAllReadMessage(SentUserMessageModel UMM, int userId) { //var userId = Convert.ToInt32(Session["LogedUserID"].ToString()); SleepingPartnermanagementTestingEntities db = new SleepingPartnermanagementTestingEntities(); List <ReciveUserMessageModel> List = new List <ReciveUserMessageModel>(); List = db.ReceiveUserMessages.OrderByDescending(id => id.Id).Where(a => a.SponserId == userId) .Select(x => new ReciveUserMessageModel { Id = x.Id, UserId = x.UserId, Message = x.Message, Sender_Name = x.Sender_Name, SponserId = x.SponserId, IsRead = x.IsRead, CreateDate = x.CreateDate }).ToList(); return(Ok(List)); }
public IHttpActionResult Inbox(SentUserMessageModel sentmodel) { //var userId = Convert.ToInt32(Session["LogedUserID"].ToString()); //string username = Session["LogedUserFullname"].ToString(); SleepingPartnermanagementTestingEntities db = new SleepingPartnermanagementTestingEntities(); SentUserMessage sent_msg = new SentUserMessage(); sent_msg.Sender = sentmodel.Sender = sentmodel.UserId; sent_msg.UserId = sentmodel.UserId = sentmodel.UserId; sent_msg.SponserId = sentmodel.SponserId; sent_msg.Sender_Name = sentmodel.Sender_Name; sent_msg.Message = sentmodel.Message; sent_msg.IsRead = sentmodel.IsRead = true; sent_msg.CreateDate = sentmodel.CreateDate = DateTime.Today; db.SentUserMessages.Add(sent_msg); ReceiveUserMessage Recive_msg = new ReceiveUserMessage(); Recive_msg.Sender = sentmodel.Sender = sentmodel.UserId; Recive_msg.UserId = sentmodel.UserId = sentmodel.UserId; Recive_msg.SponserId = sentmodel.SponserId; Recive_msg.Sender_Name = sentmodel.Sender_Name; Recive_msg.Message = sentmodel.Message; Recive_msg.IsRead = sentmodel.IsRead = false; Recive_msg.CreateDate = sentmodel.CreateDate = DateTime.Today; db.ReceiveUserMessages.Add(Recive_msg); db.SaveChanges(); var fcm = db.NewUserRegistrations.Where(x => x.UserId == sentmodel.SponserId).Select(x => x.fcm).FirstOrDefault(); if (fcm != null) { WebClient client = new WebClient(); client.DownloadString("https://sleepingpartnertesting.royalcryptoexchange.com/messageNotifyApi.php?send_notification&sname=" + sentmodel.Sender_Name + "&uid=" + sentmodel.UserId + "&sid=" + sentmodel.SponserId + "&message=" + sentmodel.Message + "&token=" + fcm); } return(Ok(new { success = true, message = "messsage sent successfully" })); }