public async Task <JsonResult> Insert() { try { var id = Guid.NewGuid(); var text = Request.Form["text"]; var mtype = Guid.Parse(Request.Form["mtype"]); var sid = Request.Form["sid"]; var rid = Guid.Parse(Request.Form["rid"]); var api = Guid.Parse(Request.Form["api"]); if (MessagingConversationService.Insert(id, text, mtype, sid, rid, DateTime.Now)) { //add notification to users that this user sent a message //do not include the uid that sent the message var receipents = MessagingRoomParticipantService.GetByRoomIDExceptUID(rid, sid); var nid = Guid.NewGuid(); NotificationService.Insert(nid, text, api, "New Message"); foreach (var r in receipents) { var nrID = Guid.NewGuid(); NotificationService.InsertNR(nrID, nid, r.UserID, api); //invoke signal r that there is a new message notification for the users //nrID=id for notificationReceipent so that if its confirmed received this id will be passed back to the //server to remove the notificationreceipent var textToSend = this.IdentifyMessageNotification(mtype.ToString(), text); NotificationManagerHub.SendNotification(nrID.ToString(), api.ToString(), r.UserID, "New Message", textToSend); MessagingAppHub.SendNotification(id.ToString(), api.ToString(), rid.ToString()); } return(Success(id.ToString())); } return(Failed(MessageUtility.ServerError())); } catch { return(Failed(MessageUtility.ServerError())); } }
public async Task <JsonResult> GetByID(string id) { try { var data = MessagingConversationService.GetByID(Guid.Parse(id)); return(Success(MessagingConversationVM.MToVM(data))); } catch { return(Failed(MessageUtility.ServerError())); } }
public async Task <JsonResult> GetByRoomID() { try { var id = Guid.Parse(Request.Form["id"]); var data = MessagingConversationService.GetByRoomID(id); return(Success(MessagingConversationVM.MsToVMs(data))); } catch { return(Failed(MessageUtility.ServerError())); } }
public async Task <JsonResult> Remove() { try { var id = Guid.Parse(Request.Form["id"]); if (MessagingConversationService.Remove(id)) { return(Success("")); } return(Failed(MessageUtility.ServerError())); } catch { return(Failed(MessageUtility.ServerError())); } }
public async Task <JsonResult> MCRemove() { try { var id = Guid.Parse(Request.Form["id"]); var rid = Guid.Parse(Request.Form["rid"]); if (MessagingConversationService.Remove(id, rid)) { return(Success(id.ToString())); } return(Failed(MessageUtilityService.FailedRemove("Conversation"))); } catch { return(Failed(MessageUtilityService.ServerError())); } }
public async Task <JsonResult> MSGetByRoom() { try { var rid = Guid.Parse(Request.Form["id"]); var aid = Guid.Parse(Request.Form["aid"]); var ia = Boolean.Parse(Request.Form["ia"]); var id = Boolean.Parse(Request.Form["isDesc"]); var data = MessagingConversationService.GetByRID(rid, ia); var vms = MessagingConversationService.SetSubDatas(data); return(Success(MessagingConversationService.OrderByDateTime(vms, id))); } catch { return(Failed(MessageUtilityService.ServerError())); } }
public async Task <JsonResult> MCUpdate() { try { var id = Guid.Parse(Request.Form["id"]); var text = Request.Form["text"]; var rid = Guid.Parse(Request.Form["rid"]); var dtid = Guid.Parse(Request.Form["dtid"]); var ia = Boolean.Parse(Request.Form["ia"]); if (MessagingConversationService.Update(id, text, rid, dtid, ia)) { return(Success(id.ToString())); } return(Failed(MessageUtilityService.FailedUpdate("Conversation"))); } catch { return(Failed(MessageUtilityService.ServerError())); } }
public async Task <JsonResult> MCInsert() { try { var id = Guid.Parse(Request.Form["id"]); var text = Request.Form["text"]; var mtid = Guid.Parse(Request.Form["mtid"]); var sid = Guid.Parse(Request.Form["sid"]); var rid = Guid.Parse(Request.Form["rid"]); var dtid = Guid.Parse(Request.Form["dtid"]); var ia = Boolean.Parse(Request.Form["ia"]); if (MessagingConversationService.Insert(id, text, mtid, sid, rid, dtid, ia)) { if (MCRInsert(rid, id, this.MCID)) { return(Success(id.ToString())); } return(Failed(MessageUtilityService.FailedInsert("Not sent to the members please try again"))); } return(Failed(MessageUtilityService.FailedInsert("Conversation"))); } catch { return(Failed(MessageUtilityService.ServerError())); } }