public new void NewsPictureInsert(NewsPicture entity) { // check permission: admin PrincipalPermission permAdmin = new PrincipalPermission(Thread.CurrentPrincipal.Identity.Name, "Administrator"); permAdmin.Demand(); TraceCallEnterEvent.Raise(); try { // check required fields: if (entity.Title.Length == 0) throw new ArgumentNullException("NewsPicture.Title", "A képaláírás nincs megadva."); if (entity.PictureUrl.Length == 0 || entity.PictureUrl == DBString.Null) throw new ArgumentNullException("NewsPicture.PictureUrl", "A fájlnév nincs megadva."); if (entity.PictureData == null || entity.PictureData.Length == 0) throw new ArgumentNullException("NewsPicture.PictureData", "A kép nincs megadva."); // logical checks: string ext = Path.GetExtension(entity.PictureUrl).ToLower(); if (!(ext.Equals(".gif") || ext.Equals(".jpg") || ext.Equals(".jpeg"))) throw new ApplicationException("Csak jpeg vagy gif formátumú kép csatolható."); FileDataContext fileDataContext = new FileDataContext(); string fileName = entity.ID.ToString() + ext; fileDataContext.NewsPictureInsert(entity.NewsRef, fileName, entity.PictureData); base.NewsPictureInsert(entity); BusinessAuditEvent.Success(); TraceCallReturnEvent.Raise(); return; } catch (Exception ex) { ExceptionManager.Publish(ex); BusinessAuditEvent.Fail( new EventParameter("Exception", ex.ToString()) ); TraceCallReturnEvent.Raise(false); throw; } }