Beispiel #1
0
 private void DeleteMemberAssessment(object obj)
 {
     if (
         MessageBox.Show("Are you Sure You want to Delete this Record?", "PinnaFit",
                         MessageBoxButton.YesNoCancel, MessageBoxImage.Warning) == MessageBoxResult.Yes)
     {
         try
         {
             SelectedMemberAssessment.Enabled = false;
             var stat = _assessmentService.Disable(SelectedMemberAssessment);
             if (stat == string.Empty)
             {
                 MemberAssessments.Remove(SelectedMemberAssessment);
             }
             else
             {
                 MessageBox.Show("Can't Delete, may be the data is already in use..."
                                 + Environment.NewLine + stat, "Can't Delete",
                                 MessageBoxButton.OK, MessageBoxImage.Error);
             }
         }
         catch (Exception ex)
         {
             MessageBox.Show("Can't Delete, may be the data is already in use..."
                             + Environment.NewLine + ex.Message + Environment.NewLine + ex.InnerException,
                             "Can't Delete",
                             MessageBoxButton.OK, MessageBoxImage.Error);
         }
     }
 }
Beispiel #2
0
        private void SaveMemberAssessment(object obj)
        {
            try
            {
                if (SelectedMember == null)
                {
                    return;
                }

                SelectedMember.DateOfBirth = BirthDate;
                var statMem = _memberService.InsertOrUpdate(SelectedMember);

                if (statMem != string.Empty)
                {
                    MessageBox.Show("Can't save Member Data"
                                    + Environment.NewLine + statMem, "Can't save", MessageBoxButton.OK,
                                    MessageBoxImage.Error);
                }

                if (SelectedMemberAssessment.Height == null || SelectedMemberAssessment.Weight == null)
                {
                    return;
                }

                var newObject = SelectedMemberAssessment.Id;
                var stat      = _assessmentService.InsertOrUpdate(SelectedMemberAssessment);
                if (stat != string.Empty)
                {
                    MessageBox.Show("Can't save Assessment Data"
                                    + Environment.NewLine + stat, "Can't save", MessageBoxButton.OK,
                                    MessageBoxImage.Error);
                }

                else if (newObject == 0)
                {
                    MemberAssessments.Insert(0, SelectedMemberAssessment);
                }
            }
            catch (Exception exception)
            {
                MessageBox.Show("Can't save"
                                + Environment.NewLine + exception.Message, "Can't save", MessageBoxButton.OK,
                                MessageBoxImage.Error);
            }
        }
Beispiel #3
0
        private void AddNewMemberAssessment()
        {
            decimal?height = null;

            if (MemberAssessments.Any())
            {
                var memberAssessmentDto = MemberAssessments.FirstOrDefault();
                if (memberAssessmentDto != null)
                {
                    height = memberAssessmentDto.Height;
                }
            }

            if (SelectedMember != null)
            {
                SelectedMemberAssessment = new MemberAssessmentDTO
                {
                    MemberId       = SelectedMember.Id,
                    AssessmentTime = DateTime.Now,
                    Height         = height
                }
            }
            ;
        }