Exemple #1
0
 public void Delete(int id)
 {
     try
     {
         InsuredRepository insuredRepository = new InsuredRepository();
         insuredRepository.Delete(id);
     }
     catch (Exception)
     {
         throw;
     }
 }
Exemple #2
0
        public ModifyInsuredViewModel(string searchText)
        {
            IsModifyDialogOpen = false;
            _errorsList.Clear();
            this.SearchText = searchText;

            ModifyCommand = new RelayCommand <object>((p) =>
            {
                if (SelectedInsured == null)
                {
                    return(false);
                }

                if (string.IsNullOrEmpty(OnModifyingInsuredName))
                {
                    return(false);
                }

                if (OnModifyingInsuredName.Length > 30)
                {
                    UpdateResultAsync(Result.HasError, "Độ dài tối đa của Họ tên nhân viên là 50 ký tự");
                }
                else
                {
                    UpdateResultAsync(Result.ExcludeError, "Độ dài tối đa của Họ tên nhân viên là 50 ký tự");
                }

                if (_errorsList.Count > 0)
                {
                    return(false);
                }
                else
                {
                    return(true);
                }
            }, (p) =>
            {
                SelectedInsured.Name = OnModifyingInsuredName;
                insuredRepository.Save();

                Success = "Đã sửa thông tin nhân viên";
                UpdateResultAsync(Result.Successful);

                SelectedInsured = null;
                OnPropertyChanged("ListInsureds");
            });

            DeleteCommand = new RelayCommand <object>((p) =>
            {
                if (SelectedInsured == null)
                {
                    return(false);
                }

                return(true);
            }, (p) =>
            {
                IsModifyDialogOpen = false;

                insuredRepository.Delete(SelectedInsured);
                insuredRepository.Save();

                Success = "Đã xóa nhân viên";
                UpdateResultAsync(Result.Successful);

                SelectedInsured = null;
                OnPropertyChanged("ListInsureds");
            });
        }