public Response CreateMarker(CreateMarkerRequest request) { try { Console.WriteLine(request); request.Marker.MarkerId = GetId(request.Marker.DocId); _dal.CreateMarker(request); CreateMarkerResponseOk ret = new CreateMarkerResponseOk { Marker = request.Marker }; _markerWebSocket.SendNewMarker(request.Marker); return(ret); } catch (Exception ex) { return(new AppResponseError(ex.Message)); } }
public async Task <Response> CreateMarker(CreateMarkerRequest request) { Response retval = new CreateMarkerResponseInvalidDocID(request); if (!_dal.IsDocumentExists(_conn, request.DocID)) { retval = new CreateMarkerResponseInvalidDocID(request); } else if (!_dal.IsUserExists(_conn, request.UserID)) { retval = new CreateMarkerResponseInvalidUserID(request); } else if (!ValidateMarkerType(request.MarkerType)) { retval = new CreateMarkerResponseInvalidMarkerType(request); } else { var id = Guid.NewGuid().ToString(); Marker marker = new Marker() { BackColor = request.BackColor, DocID = request.DocID, ForeColor = request.ForeColor, MarkerID = id , MarkerLocation = request.MarkerLocation, MarkerType = request.MarkerType, UserID = request.UserID }; try { _dal.CreateMarker(_conn, marker); retval = new CreateMarkerResponseOK(request); await _webSocket.SendNewMarker(marker); } catch (Exception ex) { retval = new AppResponseError("Error in create marker"); } } return(retval); }