Projekt

Obecné

Profil

« Předchozí | Další » 

Revize 5adba4c4

Přidáno uživatelem Vojtěch Bartička před asi 2 roky(ů)

Implemented static global config, added endpoint to set req annotations per document

Zobrazit rozdíly:

Backend/Core/Services/DocumentService/DocumentServiceEF.cs
12 12
using AutoMapper;
13 13
using Models.Users;
14 14
using Ganss.XSS;
15
using Core.StaticConfig;
15 16

  
16 17
namespace Core.Services.DocumentService
17 18
{
......
105 106
                UserAdded = userAdded,
106 107
                Name = documentName,
107 108
                Length = documentContent.Content.Length,
108
                RequiredAnnotations = 3                     // TODO this is only for testing purposes
109
                RequiredAnnotations = GlobalConfiguration.RequiredAnnotations
109 110
            };
110 111

  
111
            /*foreach (var user in users)
112
            {
113
                Annotation annotation = new Annotation()
114
                {
115
                    User = user,
116
                    UserAssigned = userAdded,
117
                    State = Models.Enums.EState.NEW,
118
                    DateAssigned = DateTime.Now,
119
                    DateLastChanged = DateTime.Now,
120
                    Document = document,
121
                    Note = ""
122
                };
123
                databaseContext.Annotations.Add(annotation);
124
            }*/
125

  
126 112
            databaseContext.DocumentContents.Add(documentContent);
127 113
            databaseContext.Documents.Add(document);
128
            databaseContext.SaveChanges();                  // Maybe do this after all the documents are added
114
            databaseContext.SaveChanges();
129 115
        }
130 116

  
131 117
        public DocumentListResponse GetDocuments(int pageIndex, int pageSize)
......
169 155
            };
170 156
        }
171 157

  
158
        public void SetRequiredAnnotationsForDocuments(SetRequiredAnnotationsRequest request)
159
        {
160
            var documents = databaseContext.Documents.Where(d => request.DocumentIds.Contains(d.Id));
161
            foreach (var doc in documents)
162
            {
163
                doc.RequiredAnnotations = request.RequiredAnnotations;
164
            }
165
            databaseContext.SaveChanges();
166
        }
172 167
    }
173 168
}

Také k dispozici: Unified diff