public async Task <Response> CreateDocument(CreateDocumentRequest request) { Response response = new CreateDocumentResponseInvalidUserID(request); if (_dal.isUserExists(request.UserID)) { try { var docID = Guid.NewGuid().ToString(); _dal.CreateDocument(request.UserID, docID, request.DocumentName, request.ImageURL); response = new CreateDocumentResponseOK(request); } catch (Exception ex) { response = new AppResponseError(ex.Message); } } return(response); }
public async Task <Response> CreateShare(CreateShareRequest request) { Response response = new CreateShareResponseInvalidUserID(request); if (_dal.isUserExists(request.Share.UserID) && _dal.isDocExists(request.Share.DocID)) { try { //create share DataSet ds = _dal.CreateShare(request.Share.DocID, request.Share.UserID); response = new CreateShareResponseOK(request); //update user for new share await _socket.Send(request.Share.UserID, "newDocumentUpdate"); } catch (Exception ex) { response = new AppResponseError(ex.Message); } } return(response); }
public async Task <Response> CreateUser(CreateUserRequest request) { Response response = new CreateUserResponseInvalidUserID(request); if (!_dal.isUserExists(request.User.UserID)) { try { DataSet ds = _dal.CreateUser(request.User.UserID, request.User.UserName); var userData = ds.Tables[0].Rows[0]; var user = new User(); user.UserID = (string)userData["USER_ID"]; user.UserName = (string)userData["USER_NAME"]; response = new CreateUserResponseOK(user); } 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); }