public async Task <Response> GetMarkers(GetMarkersRequest request) { //TODO test Response retval = new GetMarkersResponseInvalidDocID(request); if (_dal.IsDocumentExists(_conn, request.DocID)) { try { List <Marker> markers = new List <Marker>(); DataSet ds = _dal.GetMarkers(_conn, request.DocID); foreach (DataRow row in ds.Tables[0].Rows) { markers.Add(CreateMarkerFromRow(row)); } retval = new GetMarkersResponseOk(markers); } catch (Exception ex) { retval = new AppResponseError("Error in get markers"); } } return(retval); }
public Response GetAllMarkers(string documentId) { Response response = new GetMarkersResponseOk(); try { var results = _drawingDal.GetAllMarkers(documentId); var markers = results.Tables[0].AsEnumerable() .Select(row => new Marker { Color = row.Field <string>("COLOR"), DocId = documentId, OwnerUser = row.Field <string>("OWNER_USER_ID"), MarkerId = row.Field <string>("MARKER_ID"), Position = row.Field <string>("POS"), MarkerType = TryParseMarker((string)row["MARK_TYPE"]) }); ((GetMarkersResponseOk)response).Markers = markers; } catch (Exception e) { response = new AppResponseError(e.Message); } return(response); }
public Response GetMarkers(GetMarkersRequest request) { List <MarkerDto> markersList = new List <MarkerDto>(); try { var dataSet = _dal.GetMarkers(request); var table = dataSet.Tables[0]; for (int i = 0; i < dataSet.Tables[0].Rows.Count; i++) { MarkerDto temp = new MarkerDto() { DocId = table.Rows[i]["DocId"].ToString(), MarkerId = table.Rows[i]["MarkerId"].ToString(), MarkerType = table.Rows[i]["MarkerType"].ToString(), ForColor = table.Rows[i]["ForColor"].ToString(), BackColor = table.Rows[i]["BackColor"].ToString(), UserId = table.Rows[i]["UserId"].ToString(), LocationX = Convert.ToDouble(table.Rows[i]["LocationX"].ToString()), LocationY = Convert.ToDouble(table.Rows[i]["LocationY"].ToString()), Height = Convert.ToDouble(table.Rows[i]["Height"].ToString()), Width = Convert.ToDouble(table.Rows[i]["Width"].ToString()) /* * LocationX = Convert.ToInt32((decimal)table.Rows[i]["LocationX"]), * LocationY = Convert.ToInt32((decimal)table.Rows[i]["LocationY"]), * Height = Convert.ToInt32((decimal)table.Rows[i]["Height"]), * Width= Convert.ToInt32((decimal)table.Rows[i]["Width"]) */ }; markersList.Add(temp); } GetMarkersResponseOk ret = new GetMarkersResponseOk { Markers = markersList.ToArray() }; return(ret); } catch (Exception ex) { return(new AppResponseError(ex.Message)); } }