protected bool Save() { bool retVal = false; School thisSchool = null; SchoolService schoolsService = new SchoolService(); if (SessionContents.CurrentSchool != null) { thisSchool = SessionContents.CurrentSchool; } else { return false; } DocumentRepository thisDocumentRepository = new DocumentRepository(); if (thisDocumentRepository.SchoolRootFolderExists(thisSchool)) { //Check if logo needs saving, i.e. if file upload has a file if (uxFileUpload.FileBytes.Length > 0) { try { int fileSize = uxFileUpload.FileBytes.Count(); string fileExt = System.IO.Path.GetExtension(uxFileUpload.FileName); fileExt = fileExt.Replace(".", ""); if (!thisDocumentRepository.ValidSupportingDocument(fileExt)) { retVal = false; string allowedDocType = thisDocumentRepository.AllowedFileTypeList(); CustomValidator err = new CustomValidator(); err.ValidationGroup = "SaveFile"; err.IsValid = false; err.ErrorMessage = "You did not select a valid file for this screen. Please only upload files of type: " + allowedDocType; //if (fileSize > 1048576) //{ // err.ErrorMessage = "The maximun size has been extended"; //} Page.Validators.Add(err); } else { if (this.ObjectID == -1) { //save parent record stub switch (this.DocumentFunctionalObjectType) { case DocumentRepository.DocumentFunctionalObjectType.Consultation: break; case DocumentRepository.DocumentFunctionalObjectType.Issue: break; case DocumentRepository.DocumentFunctionalObjectType.Initiative: break; case DocumentRepository.DocumentFunctionalObjectType.Activity: break; case DocumentRepository.DocumentFunctionalObjectType.Star: if (SessionContents.SelectedAcademicYear != null) { } break; case DocumentRepository.DocumentFunctionalObjectType.YtaSignOff: if (SessionContents.SelectedAcademicYear != null) { SignOffService signOffsService = new SignOffService(); SignOff newSignOff = signOffsService.CreateNewObject(); newSignOff.SchoolID = thisSchool.SchoolID; newSignOff.AccreditationTypeID = 4; newSignOff.AcademicYearID = SessionContents.SelectedAcademicYear.AcademicYearID; newSignOff.YtaTravelPlan = true; newSignOff.Submitted = false; newSignOff.SignedOffBySchool = false; newSignOff.SignedOffByBorough = false; newSignOff.SignedOffByTfl = false; signOffsService.Save(newSignOff); this.ObjectID = (int)newSignOff.SignOffID; } break; case DocumentRepository.DocumentFunctionalObjectType.TravelPlan: break; case DocumentRepository.DocumentFunctionalObjectType.CaseStudy: break; } } if (this.ObjectID != -1) { thisDocumentRepository.SaveSupportingDocument(uxFileUpload, this.DocumentFunctionalObjectType, thisSchool, this.ObjectID); retVal = true; } } } catch (Exception ex) { System.Console.WriteLine("You have not specified a file."); } } else { retVal = true; } } return retVal; }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)