Example #1
0
        /// <summary>
        /// Delete all damage extents of project in the database
        /// </summary>
        /// <param name="projectId"></param>
        public void deleteDamageExtentsFromDB(int projectId)
        {
            if (projectId < 1)
            {
                return;
            }

            string _deleteQueryString =
                $"delete " +
                $"from \"DamageExtent\" " +
                $"where \"DamageExtent\".\"MappedObjectId\" in " +
                $"(select damageextent.\"MappedObjectId\" " +
                $"from \"DamageExtent\" as damageextent, \"Intensity\" as intensity " +
                $"where intensity.\"Project_Id\" = {projectId} " +
                $"and damageextent.\"IntensityId\" = intensity.\"ID\") ";

            using (var transaction = DBManager.ActiveSession.BeginTransaction())
            {
                ISQLQuery query = ActiveSession.CreateSQLQuery(_deleteQueryString);
                query.ExecuteUpdate();
                DBManager.ActiveSession.Flush();
                transaction.Commit();
            }

            //Change the project to state "Started"
            var _resultController = new ResultController();

            _resultController.setProjectStatus(projectId, 1);
        }