public async Task <Response> GetDocument(GetDocumentRequest request) { Response response = new GetDocumentResponseInvalidDocID(request); if (_dal.isDocExists(request.DocID)) { try { DataSet ds = _dal.GetDocument(request.DocID); var docData = ds.Tables[0].Rows[0]; var doc = new Document(); doc.DocID = (string)docData["DOC_ID"]; doc.UserID = (string)docData["USER_ID"]; doc.DocumentName = (string)docData["DOCUMENT_NAME"]; doc.ImageURL = (string)docData["IMAGE_URL"]; response = new GetDocumentResponseOK(doc); } catch (Exception ex) { response = new AppResponseError(ex.Message); } } return(response); }
public async Task <Response> CreateMarker(CreateMarkerRequest request) { Response response = new CreateMarkerResponseInvalidMarkerData(request); if (_dal.isUserExists(request.UserID) && _dal.isDocExists(request.DocID) && isValidMarkerType(request.MarkerType)) { try { //create marker var markerID = Guid.NewGuid().ToString(); DataSet ds = _dal.CreateMarker(request.DocID, markerID, request.UserID, request.MarkerType, request.StrokeColor, request.BackgroundColor, request.X, request.Y, request.XRadius, request.YRadius); response = new CreateMarkerResponseOK(request); //update other users List <string> usersIDs = new List <string>(); DataSet ds2 = _dal.GetSharedUsers(request.DocID); foreach (DataRow row in ds2.Tables[0].Rows) { usersIDs.Add((string)row["USER_ID"]); } DataSet ds3 = _dal.GetDocument(request.DocID); DataRow docData = ds3.Tables[0].Rows[0]; usersIDs.Add((string)docData["USER_ID"]); foreach (string userID in usersIDs) { await _socket.Send(userID, "newMarkerUpdate"); } } catch (Exception ex) { response = new AppResponseError(ex.Message); } } return(response); }