private void Save() { if (!ValidData()) { string msg = null; foreach (RuleViolation viol in RulesViolations) { msg += viol.ErrorMessage; } RulesViolations.Clear(); Helper.ShowMessage(msg); return; } try { WriteModelValues(_currnetModel); if (_modelState == ModelState.New) { _repository.Add(_currnetModel); } _unitOfWork.Save(); SetState(ModelState.Saved); } catch (Exception ex) { Helper.LogAndShow(ex); } }
void Save() { if (!ValidData()) { string msg = null; foreach (var viol in RulesViolations) { msg += viol.ErrorMessage; } RulesViolations.Clear(); Helper.ShowMessage(msg); return; } try { WriteModelValues(_currnetModel); if (_modelState == ModelState.New) { _currnetModel.LoanStatus = LoansStatuses.Single(x => x.Id == 1); _repository.Add(_currnetModel); } _unitOfWork.Save(); SetState(ModelState.Saved); } catch (Exception ex) { string msg = Helper.ProcessExceptionMessages(ex); Helper.ShowMessage(msg); } }