public Insured Find(int id) { try { InsuredRepository insuredRepository = new InsuredRepository(); return(insuredRepository.Find(id)); } catch (Exception) { throw; } }
public void Insert(Insured obj) { try { InsuredRepository insuredRepository = new InsuredRepository(); insuredRepository.Insert(obj); } catch (Exception) { throw; } }
public void Delete(int id) { try { InsuredRepository insuredRepository = new InsuredRepository(); insuredRepository.Delete(id); } catch (Exception) { throw; } }
public NewInsuredViewModel() { _errorsList.Clear(); InsuredRepository insuredRepository = new InsuredRepository(); AddCommand = new RelayCommand <object>((p) => { if (string.IsNullOrEmpty(this.InputId)) { return(false); } if (string.IsNullOrEmpty(this.InputName)) { return(false); } if (this.InputId.Length > 30) { UpdateResultAsync(Result.HasError, "Độ dài tối đa của số CMT/CCCD là 30 ký tự"); } else { UpdateResultAsync(Result.ExcludeError, "Độ dài tối đa của số CMT/CCCD là 30 ký tự"); } if (this.InputName.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ự"); } var creatingInsured = insuredRepository.GetInsured(this.InputId); if (creatingInsured != null) { UpdateResultAsync(Result.HasError, "Số CMT/CCCD này đã tồn tại"); } else { UpdateResultAsync(Result.ExcludeError, "Số CMT/CCCD này đã tồn tại"); } if (_errorsList.Count > 0) { return(false); } else { return(true); } }, (p) => { Insured newInsured = new Insured(); newInsured.Id = this.InputId.Trim(' '); newInsured.Name = this.InputName.Trim(' '); insuredRepository.Add(newInsured); insuredRepository.Save(); Success = "Đã tạo nhân viên"; UpdateResultAsync(Result.Successful); InputId = null; InputName = null; IsStartOver = true; OnPropertyChanged("IsStartOver"); IsStartOver = false; }); }