Exemplo n.º 1
0
        /// <summary>
        /// Handles the Delete event of the gList control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="RowEventArgs"/> instance containing the event data.</param>
        protected void gList_Delete(object sender, RowEventArgs e)
        {
            RockTransactionScope.WrapTransaction(() =>
            {
                var projectPointOfAssessmentService = new ResidencyService <ProjectPointOfAssessment>();

                ProjectPointOfAssessment projectPointOfAssessment = projectPointOfAssessmentService.Get((int)e.RowKeyValue);
                if (projectPointOfAssessment != null)
                {
                    string errorMessage;
                    if (!projectPointOfAssessmentService.CanDelete(projectPointOfAssessment, out errorMessage))
                    {
                        mdGridWarning.Show(errorMessage, ModalAlertType.Information);
                        return;
                    }

                    projectPointOfAssessmentService.Delete(projectPointOfAssessment, CurrentPersonId);
                    projectPointOfAssessmentService.Save(projectPointOfAssessment, CurrentPersonId);

                    int iProjectId = hfProjectId.ValueAsInt();

                    // after an item is deleted, we need to renumber all the items
                    List <ProjectPointOfAssessment> items = projectPointOfAssessmentService.Queryable().Where(a => a.ProjectId == iProjectId).OrderBy(a => a.AssessmentOrder).ToList();
                    UpdateItemOrders(projectPointOfAssessmentService, items);
                }
            });

            BindGrid();
        }
Exemplo n.º 2
0
        /// <summary>
        /// Handles the Delete event of the gList control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="RowEventArgs"/> instance containing the event data.</param>
        protected void gList_Delete(object sender, RowEventArgs e)
        {
            RockTransactionScope.WrapTransaction(() =>
            {
                var groupMemberService = new GroupMemberService();
                int groupMemberId      = (int)e.RowKeyValue;

                GroupMember groupMember = groupMemberService.Get(groupMemberId);
                if (groupMember != null)
                {
                    // check if person can be removed from the Group and also check if person can be removed from all the person assigned competencies
                    string errorMessage;
                    if (!groupMemberService.CanDelete(groupMember, out errorMessage))
                    {
                        mdGridWarning.Show(errorMessage, ModalAlertType.Information);
                        return;
                    }

                    var competencyPersonService = new ResidencyService <CompetencyPerson>();
                    var personCompetencyList    = competencyPersonService.Queryable().Where(a => a.PersonId.Equals(groupMember.PersonId));
                    foreach (var item in personCompetencyList)
                    {
                        if (!competencyPersonService.CanDelete(item, out errorMessage))
                        {
                            mdGridWarning.Show(errorMessage, ModalAlertType.Information);
                            return;
                        }
                    }

                    // if you made it this far, delete all person's assigned competencies, and finally delete from Group
                    foreach (var item in personCompetencyList)
                    {
                        competencyPersonService.Delete(item, CurrentPersonId);
                        competencyPersonService.Save(item, CurrentPersonId);
                    }

                    groupMemberService.Delete(groupMember, CurrentPersonId);
                    groupMemberService.Save(groupMember, CurrentPersonId);
                }
            });

            BindGrid();
        }
Exemplo n.º 3
0
        /// <summary>
        /// Handles the Delete event of the gList control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="RowEventArgs"/> instance containing the event data.</param>
        protected void gList_Delete(object sender, RowEventArgs e)
        {
            RockTransactionScope.WrapTransaction(() =>
            {
                var trackService = new ResidencyService <Track>();
                Track track      = trackService.Get((int)e.RowKeyValue);

                if (track != null)
                {
                    string errorMessage;
                    if (!trackService.CanDelete(track, out errorMessage))
                    {
                        mdGridWarning.Show(errorMessage, ModalAlertType.Information);
                        return;
                    }

                    trackService.Delete(track, CurrentPersonId);
                    trackService.Save(track, CurrentPersonId);
                }
            });

            BindGrid();
        }
Exemplo n.º 4
0
        /// <summary>
        /// Handles the Delete event of the gList control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="RowEventArgs"/> instance containing the event data.</param>
        protected void gList_Delete(object sender, RowEventArgs e)
        {
            RockTransactionScope.WrapTransaction(() =>
            {
                var competencyPersonProjectService = new ResidencyService <CompetencyPersonProject>();
                CompetencyPersonProject competencyPersonProject = competencyPersonProjectService.Get((int)e.RowKeyValue);

                if (competencyPersonProject != null)
                {
                    string errorMessage;
                    if (!competencyPersonProjectService.CanDelete(competencyPersonProject, out errorMessage))
                    {
                        mdGridWarning.Show(errorMessage, ModalAlertType.Information);
                        return;
                    }

                    competencyPersonProjectService.Delete(competencyPersonProject, CurrentPersonId);
                    competencyPersonProjectService.Save(competencyPersonProject, CurrentPersonId);
                }
            });

            BindGrid();
        }