11using System ;
22using System . Collections . Generic ;
33using System . Linq ;
4+ using MedHelp . Data ;
45using MedHelp . Models ;
6+ using Microsoft . AspNetCore . Authorization ;
57using Microsoft . AspNetCore . Mvc ;
68
79namespace MedHelp . Controllers
810{
11+ [ Authorize ]
912 [ Route ( "api/[controller]" ) ]
1013 public class LastOpenedDocumentsController : Controller
1114 {
12- private static readonly Template [ ] Templates =
13- {
14- new Template
15- {
16- Name = "Справка о приеме" ,
17- Description = "Самая обычная справка о приеме какая только может быть" ,
18- ImagePath = "https://pp.userapi.com/c638519/v638519335/547d6/N8qDUbqrCG4.jpg"
19- } ,
20- new Template
21- {
22- Name = "Направление на анализы" ,
23- Description = "Куда сказано, туда и иди" ,
24- ImagePath = "https://pp.userapi.com/c630317/v630317313/1303d/i-eVXtwVRSo.jpg"
25- } ,
26- new Template
27- {
28- Name = "Направление к другому врачу" ,
29- Description = "Ну, в этой ситуации я как бы уже это... Мои полномочия уже как бы всё... Окончены!" ,
30- ImagePath = "https://pp.userapi.com/c623226/v623226313/4ab8b/RJ8H-rRuc3U.jpg"
31- }
32- } ;
15+ private readonly MedHelpContext _context ;
3316
34- private static readonly string [ ] Patients =
17+ public LastOpenedDocumentsController ( MedHelpContext context )
3518 {
36- "Наглая бабка, у которой болит мизинец на ноге" ,
37- "Дедуля" ,
38- "Ребенок, у которого 36.9"
39- } ;
19+ _context = context ;
20+ }
4021
41- [ HttpGet ]
4222 [ HttpGet ( "[action]" ) ]
43- public IEnumerable < LastOpenedDocument > LastOpenedDocuments ( )
23+ public IEnumerable < LastOpenedDocument > GetLastOpenedDocuments ( )
4424 {
45- var random = new Random ( ) ;
46- return Enumerable . Range ( 1 , 3 ) . Select ( index => new LastOpenedDocument
47- {
48- Template = Templates [ random . Next ( Templates . Length ) ] ,
49- Patient = Patients [ random . Next ( Patients . Length ) ] ,
50- LastOpenedTime = DateTime . Now . AddHours ( - random . Next ( 10 ) )
51- } ) ;
25+ return _context . LastOpenedDocuments ;
5226 }
5327 }
5428}
0 commit comments