protected void BtnConfirmDeleting_Click(object sender, EventArgs e)
        {
            try
            {
                Int32 IdToDelete = Convert.ToInt32(HydIdToDelete.Value);

                DocumentEFRepository rep = new DocumentEFRepository("");
                Document             DocToStoreInAudit = rep.SelectEntity(IdToDelete);

                //cancella i capitoli associati
                DeleteChapters(DocToStoreInAudit.IdDocument);
                //cancella la riga del documento
                DeleteEntity(IdToDelete);

                //cancella il pdf fisico
                string DestPdfFullPath = HttpContext.Current.Server.MapPath("~/Public/Images/");
                string PdfName         = DocToStoreInAudit.PDFName;

                if (PdfName != null)
                {
                    System.IO.File.Delete(DestPdfFullPath + PdfName);

                    AuditPageManager ObjPageManager = new AuditPageManager();
                    ObjPageManager.InsertAudit(LoginUsr, "Document deleted: " + DocToStoreInAudit.DocName);
                }
                BindRepeater();
                DivDelete.Attributes.Add("Class", "ParentDivDeleting Disattivato");
            }
            catch (Exception ex)
            {
                PrintError(ex);
            }
        }
        public List <DocumentDTO> GetDocs()
        {
            using (DocumentEFRepository Rep = new DocumentEFRepository(""))
            {
                List <Document>    Docs           = Rep.Context.Documents.ToList();
                List <DocumentDTO> LstDocumentDTO = new List <DocumentDTO>();
                var config = new MapperConfiguration(cfg =>
                {
                    cfg.CreateMap <Document, DocumentDTO>()
                    .ForMember(dest => dest.IdDocument, opt => opt.MapFrom(src => src.IdDocument))
                    .ForMember(dest => dest.Typology, opt => opt.MapFrom(src => src.Type.Typology))
                    .ForMember(dest => dest.Enabled, opt => opt.MapFrom(src => (((bool)src.Enabled) ? "YES" : "NO")));
                });

                IMapper mapper = config.CreateMapper();

                LstDocumentDTO = mapper.Map <List <Document>, List <DocumentDTO> >(Docs);

                //foreach (User Usr in Users)
                //{
                //  List<Audit> LstAud = Usr.Audits.ToList();
                //    Role Rol = Usr.Role;
                //}

                return(LstDocumentDTO);
            }
        }
 public void DeleteEntity(Int32 IdEntity)
 {
     using (DocumentEFRepository DocRep = new DocumentEFRepository(""))
     {
         var entity = new Document {
             IdDocument = IdEntity
         };
         DocRep.Context.Entry(entity).State = EntityState.Deleted;
         DocRep.Context.SaveChanges();
     }
 }
        public Document GetSelectedDocument(int IdEntity)
        {
            Document Ent = null;

            using (DocumentEFRepository Rep = new DocumentEFRepository(""))
            {
                Ent = Rep.Context.Documents.Where(x => x.IdDocument == IdEntity).FirstOrDefault();
            }

            return(Ent);
        }
Beispiel #5
0
        public Document UpdateFileNameOfDoc(int Id, string PDFName)
        {
            Document result = null;

            using (DocumentEFRepository Rep = new DocumentEFRepository(""))
            {
                result = Rep.Context.Documents.SingleOrDefault(x => x.IdDocument == Id);
                if (result != null)
                {
                    result.PDFName = PDFName;
                    Rep.Context.SaveChanges();
                }
            }
            return(result);
        }
Beispiel #6
0
        public Document UpdateDoc(int Id)
        {
            Document result = null;

            using (DocumentEFRepository Rep = new DocumentEFRepository(""))
            {
                result = Rep.Context.Documents.SingleOrDefault(x => x.IdDocument == Id);
                if (result != null)
                {
                    result.DocName    = TxtNomeDocumento.Text;
                    result.Argument   = TxtArgument.Text;
                    result.Enabled    = Convert.ToBoolean(CboEnable.SelectedValue);
                    result.Device     = TxtDevice.Text;
                    result.Alias      = TxtAlias.Text;
                    result.DocNumer   = TxtDocNumber.Text;
                    result.IdTypology = Convert.ToInt32(CboTypology.SelectedValue);
                    Rep.Context.SaveChanges();
                }
            }
            return(result);
        }
Beispiel #7
0
        public Document InsertDoc()
        {
            Document NewDocument = new Document();


            NewDocument.DocName    = TxtNomeDocumento.Text;
            NewDocument.Argument   = TxtArgument.Text;
            NewDocument.Device     = TxtDevice.Text;
            NewDocument.Alias      = TxtAlias.Text;
            NewDocument.DocNumer   = TxtDocNumber.Text;
            NewDocument.Enabled    = Convert.ToBoolean(CboEnable.SelectedValue);
            NewDocument.IdTypology = Convert.ToInt32(CboTypology.SelectedValue);


            using (DocumentEFRepository DocRep = new DocumentEFRepository(""))
            {
                DocRep.Context.Documents.Add(NewDocument);
                DocRep.Context.SaveChanges();
            }

            return(NewDocument);
        }