Пример #1
0
        public Guid Create(int organisationId, int centreId, int categoryId, string studentCode, string studentName, string description, string fileName, byte[] contents)
        {
            var newGuid  = Guid.NewGuid();
            var category =
                PersonnelDataService.RetrieveDocumentTypes(organisationId)
                .FirstOrDefault(e => e.DocumentCategoryId == categoryId);
            var centre            = PersonnelDataService.RetrieveCentre(organisationId, centreId, e => true);
            var basePath          = CreateCentreBase(category.BasePath, centre.Name);
            var categoryFileName  = string.Concat(category.Name, "_", newGuid, "_", fileName);
            var employeeDirectory = GetStudentDirectory(basePath, studentCode) ?? CreateStudentDirectory(basePath, studentName, studentCode);
            var categoryDirectory = Path.Combine(employeeDirectory, category.Name);
            var filePath          = Path.Combine(categoryDirectory, categoryFileName);

            Directory.CreateDirectory(categoryDirectory);
            File.WriteAllBytes(filePath, contents);
            var document = new Entity.Document()
            {
                CentreId        = centreId,
                DocumentTypeId  = categoryId,
                StudentCode     = studentCode,
                CreatedDateTime = DateTime.UtcNow.Date,
                Description     = description,
                FileName        = fileName,
                Location        = filePath,
                StudentName     = studentName,
                Guid            = newGuid
            };

            PersonnelDataService.Create <Entity.Document>(organisationId, document);
            return(newGuid);
        }
Пример #2
0
        public Centre RetrieveCentre(int organisationId, int centreId, Expression <Func <Centre, bool> > predicate)
        {
            var centre = _personnelDataService.RetrieveCentre(organisationId, centreId, p => true);

            return(centre);
        }