Exemplo n.º 1
0
        public int DeletePunchItemImages(int inspectionTransID)
        {
            int result = 0;

            try
            {
                result = PunchListImageDO.DeletePunchListImageList(conn, inspectionTransID);
            }
            catch (Exception ex)
            {
                Debug.WriteLine("Exception Occured in DeletePunchItemImages method due to " + ex.Message);
            }
            return(result);
        }
        public int DeleteInspectionTransactionNotSync(Inspection inspection)
        {
            int inspectionTransactionResult = 0;

            try
            {
                IEnumerable <InspectionTransactionDO> inspections = inspectionTransactionRepository.GetEntities();

                InspectionTransactionDO inspectionTransactionDO = inspections.FirstOrDefault(ins => ins.InspectionID == inspection.inspectionID && ins.ProjectID == inspection.projectID);
                inspectionTransactionResult = inspectionTransactionRepository.DeleteEntity(inspectionTransactionDO.ID);
                LocationImageDo.DeleteImage(conn, inspectionTransactionDO.ID);
                DocumentDO.DeleteDocument(conn, inspection.inspectionID, inspection.projectID);
                PunchListDO.DeletePunchList(conn, inspection.inspectionID, inspection.projectID);
                PunchListImageDO.DeletePunchListImageList(conn, inspection.ID);
                ReportDO.DeleteReports(conn, inspection.ID);
                using (var optService = new OptionTransactionService(conn))
                {
                    var optIds = optService.GetOptionTransactionsForInspection(inspection.ID).Select(s => s.ID);
                    OptionTransactionDO.DeleteInspectionOptions(conn, inspection.ID);
                    if (optIds != null && optIds.Count() > 0)
                    {
                        foreach (var optID in optIds)
                        {
                            var chkTransIDs = CheckListTransactionDO.GetCheckListTransaction(conn, optID).Select(s => s.ID);
                            CheckListTransactionDO.DeletecheckList(conn, optID);
                            OptionTransactionImageDO.DeleteOptionImagesSync(conn, optID);
                            if (chkTransIDs != null && chkTransIDs.Count() > 0)
                            {
                                foreach (var chkId in chkTransIDs)
                                {
                                    GuildedPhotoDO.DeleteGuidedImageList(conn, chkId);
                                }
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine("Exception Occured in DeleteInspectionTransaction method due to " + ex.Message);
            }
            return(inspectionTransactionResult);
        }