//Close Claim public void CloseClaim(ClaimsProgress claimsProgress, DateTime paidDate, int totalPaid) { Claim claim = db.Claims.SingleOrDefault(claim => claim.Id == claimsProgress.ClaimId); claim.PaidDate = paidDate; claim.TotalPaid = totalPaid; Save(); }
//Insert/Delete Methods public void Add(ClaimsProgress claimProgress) { db.ClaimsProgresses.InsertOnSubmit(claimProgress); }
public void Delete(ClaimsProgress claim) { db.ClaimsProgresses.DeleteOnSubmit(claim); }
public ClaimBaseViewModel() { IsDeleteDialogOpen = false; _errorsList.Clear(); IsShowClaimOptions = false; ShowClaimOptions = new RelayCommand <object>((p) => { if (IsInsuredSelected == false) { return(false); } return(true); }, (p) => { IsShowClaimOptions = true; }); #region Add Command AddCommand = new RelayCommand <object>((p) => { if (NewExaminationDate == null) { return(false); } if (ClaimReceivedDate == null) { return(false); } if (ValidSelectedPolicy < 1) { return(false); } if (ClaimReceivedDate < NewExaminationDate) { UpdateResultAsync(Result.HasError, "Ngày nhận hồ sơ phải trùng hoặc sau ngày khám"); } else { UpdateResultAsync(Result.ExcludeError, "Ngày nhận hồ sơ phải trùng hoặc sau ngày khám"); } if (_errorsList.Count > 0) { return(false); } else { return(true); } }, (p) => { Claim newClaim = new Claim(); newClaim.PolicyId = ValidSelectedPolicy; newClaim.ExaminationDate = (DateTime)NewExaminationDate; newClaim.ReceivedDate = (DateTime)ClaimReceivedDate; claimRepository.Add(newClaim); claimRepository.Save(); Success = "Đã lập hồ sơ bồi thường"; UpdateResultAsync(Result.Successful); OnPropertyChanged("ClaimListByInsured"); OnPropertyChanged("ListNotYetClosedClaim"); OnPropertyChanged("TotalNotYetClosedClaim"); OnPropertyChanged("TotalPaidClaim"); NewExaminationDate = null; ValidSelectedPolicy = 0; ClaimReceivedDate = null; }); #endregion #region Update Command UpdateCommand = new RelayCommand <object>((p) => { if (!IsClaimSelected) { return(false); } if (ClaimProgressDate == null) { return(false); } if (ClaimProgressDate < SelectedClaim.ExaminationDate) { UpdateResultAsync(Result.HasError, "Ngày cập nhật/đóng hồ sơ phải sau ngày khám"); } else { UpdateResultAsync(Result.ExcludeError, "Ngày cập nhật/đóng hồ sơ phải sau ngày khám"); } if (SelectedClaim.IsClosed) { UpdateResultAsync(Result.HasError, "Hồ sơ này đã đóng, không thể cập nhật nữa"); } else { UpdateResultAsync(Result.ExcludeError, "Hồ sơ này đã đóng, không thể cập nhật nữa"); } if (IsPaid && ClaimTotalPaid <= 0) { UpdateResultAsync(Result.HasError, "Số tiền bồi thường phải lớn hơn 0"); } else { UpdateResultAsync(Result.ExcludeError, "Số tiền bồi thường phải lớn hơn 0"); } if (!IsClaimClosed) { if (String.IsNullOrEmpty(ClaimProgressRemarks) || String.IsNullOrWhiteSpace(ClaimProgressRemarks)) { return(false); } } if (_errorsList.Count > 0) { return(false); } else { return(true); } }, (p) => { ClaimsProgress newClaimsProgress = new ClaimsProgress(); newClaimsProgress.ClaimId = SelectedClaimId; if (IsClaimClosed) { if (IsPaid) { claimRepository.CloseClaim(newClaimsProgress, (DateTime)ClaimProgressDate, ClaimTotalPaid); } else { claimRepository.CloseClaim(newClaimsProgress, (DateTime)ClaimProgressDate, 0); } Success = "Đã đóng hồ sơ bồi thường"; } else { newClaimsProgress.Date = (DateTime)ClaimProgressDate; newClaimsProgress.Remarks = ClaimProgressRemarks; claimProgressRepository.Add(newClaimsProgress); claimProgressRepository.Save(); Success = "Đã cập nhật hồ sơ bồi thường"; } OnPropertyChanged("SelectedClaim"); UpdateResultAsync(Result.Successful); SelectedClaimId = 0; ClaimProgressRemarks = String.Empty; ClaimProgressDate = null; IsClaimClosed = false; ClaimTotalPaid = 0; OnPropertyChanged("ClaimProgressList"); OnPropertyChanged("ListNotYetClosedClaim"); OnPropertyChanged("TotalNotYetClosedClaim"); OnPropertyChanged("ListPaidClaim"); OnPropertyChanged("TotalPaidClaim"); OnPropertyChanged("ListDeniedClaim"); OnPropertyChanged("TotalDeniedClaim"); }); #endregion #region Delete Command DeleteCommand = new RelayCommand <object>((p) => { if (SelectedViewClaim == null) { return(false); } return(true); }, (p) => { IsDeleteDialogOpen = false; claimRepository.Delete(SelectedViewClaim); claimRepository.Save(); Success = "Đã xóa hồ sơ bồi thường"; UpdateResultAsync(Result.Successful); SelectedClaimIdForView = 0; OnPropertyChanged("SelectedClaimIdForView"); OnPropertyChanged("ListNotYetClosedClaim"); OnPropertyChanged("ListPaidClaim"); OnPropertyChanged("ListDeniedClaim"); OnPropertyChanged("TotalNotYetClosedClaim"); OnPropertyChanged("TotalPaidClaim"); OnPropertyChanged("TotalDeniedClaim"); }); #endregion }