public async Task <JsonResult> CreateConnection() { try { var uid = Request.Form["UID"]; var conName = Request.Form["CNAME"]; var API = Guid.Parse(Request.Form["API"]); var cid = Guid.NewGuid(); ConnectionServices.Insert(cid, true, conName, DateTime.Now, API); var mid = Guid.NewGuid(); ConnectionMemberService.InsertMember(mid, Guid.Parse(uid), cid.ToString(), DateTime.Now, false, true); return(Json(new { success = true })); } catch { return(Json(new { success = false, message = MessageUtility.ServerError() })); } }
public async Task <JsonResult> LeaveConnection() { try { var mid = Request.Form["MID"]; var uid = Request.Form["UID"]; var cid = Request.Form["CID"]; var conn = ConnectionServices.GetByID(cid); ConnectionMemberService.UpdateMemberStatus(mid, true); //if there no active users in this connection then remove this data from the database if (conn.Members.Where(x => x.isArchived == false).Count() <= 0) { //remove data from database ConnectionMemberService.RemoveMembersByConnectionID(cid); ConnectionServices.RemoveConnection(cid); } return(Json(new { success = true })); } catch { return(Json(new { success = false, message = MessageUtility.ServerError() })); } }
public async Task <JsonResult> AcceptRequest() { try { var rid = Request.Form["RID"]; //connID var cid = Request.Form["CID"]; //recquestTo UID var rtID = Request.Form["RTID"]; //checks if it is already existing var data = ConnectionServices.GetByUIDConnectionID(rtID, cid); if (data == null) { //create if not existing yet var id = Guid.NewGuid(); ConnectionMemberService.InsertMember(id, Guid.Parse(rtID), cid, DateTime.Now, false, false); RequestService.UpdateStatus(true, rid); //signalR notify accepted request is a standalone now if you want to invoke it please access it via api return(Json(new { success = true })); } else if (data.isArchived) { //if data already exist then unarchive it ConnectionMemberService.UpdateMemberStatus(data.ID.ToString(), false); RequestService.UpdateStatus(true, rid); //signalR notify accepted request is a standalone now if you want to invoke it please access it via api return(Json(new { success = true })); } else if (!data.isArchived) { RequestService.UpdateStatus(true, rid); return(Json(new { success = false, message = MessageUtility.AlreadyMember() })); } return(Json(new { success = false, message = MessageUtility.ServerError() })); } catch { return(Json(new { success = false, message = MessageUtility.ServerError() })); } }