public int InsertFile(Models.File file) { var entity = new File { AcademicYear = file.AcademicYear, DateCreated = file.DateCreated, FileStatus = FileStatus.InProgress, Education = _educationRepository.Table.First(education => education.Name == file.Education), Student = _studentRepository.Table.First(student => student.Email == file.StudentMail) }; _fileRepository.Insert(entity); return(entity.Id); }
public Models.File GetFileByFileId(int fileId) { var file = _fileRepository.GetById(fileId); var serviceFile = new Models.File { StudentFirstName = file.Student.FirstName, StudentName = file.Student.Name, StudentMail = file.Student.Email }; foreach (var request in file.Requests) { foreach (var requestPartimInformation in request.RequestPartimInformations) { var serviceModule = new Models.Module { Name = requestPartimInformation.PartimInformation.Module.Name }; var servicePartim = new Partim { Name = requestPartimInformation.PartimInformation.Partim.Name, Evidence = request.Evidence.Select(e => new Evidence { Path = e.Path, Description = e.Description, Id = e.Id, StudentEmail = e.Student.Email }), PrevEducations = request.PrevEducations.Select(e => new PrevEducation { Id = e.Id, Education = e.Education }), FileId = request.FileId, RequestId = request.Id, Status = (Models.Status)requestPartimInformation.Status, PartimInformationId = requestPartimInformation.PartimInformationId }; serviceFile.InsertModule(serviceModule); serviceFile.InsertPartim(servicePartim, serviceModule.Name); } } return(serviceFile); }