77using System . Net ;
88using System . Net . Http ;
99using System . Web . Http ;
10+ using Microsoft . AspNet . SignalR ;
1011using Microsoft . Practices . EnterpriseLibrary . Logging ;
1112using MongoDB . Bson ;
1213using MongoRepository ;
1314using Ndot . Helpers ;
15+ using Ndot . Hubs ;
1416using Ndot . Models ;
1517using ZXing ;
1618
@@ -29,15 +31,14 @@ public Sr1FormController(LogWriter logger, IRepository<Sr1FormData> repository,
2931 _apiAgent = apiAgent ;
3032 }
3133
32- [ Authorize ]
34+ [ System . Web . Http . Authorize ]
3335 public IEnumerable < Sr1FormData > Get ( )
3436 {
3537 var results = _repository . Collection . FindAllAs < Sr1FormData > ( ) . ToList ( ) ;
36- results . Add ( GetTestForm ( ) ) ;
3738 return results ;
3839 }
3940
40- [ Authorize ]
41+ [ System . Web . Http . Authorize ]
4142 public Sr1FormData Get ( string id )
4243 {
4344 return _repository . Collection . FindOneByIdAs < Sr1FormData > ( new ObjectId ( id ) ) ;
@@ -56,6 +57,8 @@ public HttpResponseMessage Post(Sr1ClientFormData clientFormData)
5657 Street = clientFormData . Street ,
5758 City = clientFormData . City ,
5859 County = clientFormData . County ,
60+ Latitude = clientFormData . Latitude ,
61+ Longitude = clientFormData . Longitude ,
5962 CreatedDate = DateTime . Now ,
6063 Actors = new List < Actor > ( )
6164 } ;
@@ -116,6 +119,10 @@ public HttpResponseMessage Post(Sr1ClientFormData clientFormData)
116119 }
117120
118121 _repository . Add ( form ) ;
122+
123+ var hubContext = GlobalHost . ConnectionManager . GetHubContext < IncidentsHub > ( ) ;
124+ hubContext . Clients . All . addNewMarkerToPage ( form . Latitude , form . Longitude ,
125+ form . Street , form . CreatedDate . ToString ( ) , form . Actors . Count ) ;
119126 }
120127 catch ( Exception e )
121128 {
@@ -146,73 +153,6 @@ private void ValidateClientFormData(Sr1ClientFormData clientFormData)
146153 throw new HttpResponseException ( HttpStatusCode . PreconditionFailed ) ;
147154 }
148155
149- private static Sr1FormData GetTestForm ( )
150- {
151- return new Sr1FormData
152- {
153- Id = "1232323" ,
154- Street = "123 Elm Street" ,
155- City = "Las Vegas" ,
156- County = "Clark" ,
157- CreatedDate = DateTime . Now ,
158- Actors = new List < Actor >
159- {
160- new Actor
161- {
162- Type = "Driver" ,
163- Driver = new DriverInfo
164- {
165- FirstName = "John" ,
166- MiddleName = "Z" ,
167- LastName = "Xamarin" ,
168- Street = "331 Main St." ,
169- City = "Las Vegas" ,
170- State = "NV" ,
171- Zip = "89129" ,
172- DriverLicenseNumber = "124234422" ,
173- DriverLicenseState = "NV" ,
174- Dob = new DateTime ( 1990 , 12 , 3 ) ,
175- LicensePlateNumber = "883GWN" ,
176- LicensePlateState = "NV" ,
177- Year = "2002" ,
178- Make = "Nissan Sentra" ,
179- BodyType = "Car" ,
180- Vin = "231XJKJ9934KKJKJDKFJ"
181- } ,
182- Owner = new OwnerInfo
183- {
184- FirstName = "Bon" ,
185- MiddleName = "Z" ,
186- LastName = "Jonas" ,
187- Street = "423 Zebas St." ,
188- City = "Las Vegas" ,
189- State = "NV" ,
190- Zip = "89123" ,
191- DriverLicenseNumber = "J2KJ2KJ3K" ,
192- DriverLicenseState = "NV" ,
193- Dob = new DateTime ( 1949 , 4 , 2 )
194- }
195- } ,
196- new Actor
197- {
198- Type = "Pedestrian" ,
199- OwnerSameAsDriver = true ,
200- Driver = new DriverInfo
201- {
202- FirstName = "Jenny" ,
203- MiddleName = "Z" ,
204- LastName = "Xamarin" ,
205- Street = "331 Main St." ,
206- City = "Las Vegas" ,
207- State = "NV" ,
208- Zip = "89129" ,
209- Dob = new DateTime ( 1990 , 12 , 3 ) ,
210- }
211- }
212- }
213- } ;
214- }
215-
216156 private static OwnerInfo GetOwnerInfoFromDlData ( DlBarCodeData dlData )
217157 {
218158 return new OwnerInfo
@@ -230,23 +170,6 @@ private static OwnerInfo GetOwnerInfoFromDlData(DlBarCodeData dlData)
230170 } ;
231171 }
232172
233- private static OwnerInfo CopyDriverInfoToOwnerInfo ( Actor actor )
234- {
235- return new OwnerInfo
236- {
237- FirstName = actor . Driver . FirstName ,
238- MiddleName = actor . Driver . MiddleName ,
239- LastName = actor . Driver . LastName ,
240- Street = actor . Driver . Street ,
241- City = actor . Driver . City ,
242- State = actor . Driver . State ,
243- Zip = actor . Driver . Zip ,
244- DriverLicenseNumber = actor . Driver . DriverLicenseNumber ,
245- DriverLicenseState = actor . Driver . DriverLicenseState ,
246- Dob = actor . Driver . Dob
247- } ;
248- }
249-
250173 private static DriverInfo GetDriverInfoFromDlData ( DlBarCodeData dlData , ClientActor clientActor )
251174 {
252175 return new DriverInfo
0 commit comments