public bool ObjectExists(ChartofAccountDTO chartofAccount) { var objectExists = false; var iDbContext = DbContextUtil.GetDbContextInstance(); try { var catRepository = new Repository <ChartofAccountDTO>(iDbContext); var catExists = catRepository .Query() .Filter(bp => bp.AccountId == chartofAccount.AccountId && bp.Id != chartofAccount.Id) .Get() .FirstOrDefault(); if (catExists != null) { objectExists = true; } } finally { iDbContext.Dispose(); } return(objectExists); }
public string Validate(ChartofAccountDTO chartofAccount) { if (null == chartofAccount) { return(GenericMessages.ObjectIsNull); } return(string.Empty); }
private void ExecuteAddNewAccountCommand() { SelectedChartofAccount = new ChartofAccountDTO { }; if (AccountTypes != null) { var comercialBank = AccountTypes.FirstOrDefault(); SelectedAccountType = comercialBank ?? AccountTypes.FirstOrDefault(); } AddNewAccountCommandVisibility = true; }
public string Disable(ChartofAccountDTO chartofAccount) { if (chartofAccount == null) { return(GenericMessages.ObjectIsNull); } string stat; try { _chartofAccountRepository.Update(chartofAccount); _unitOfWork.Commit(); stat = string.Empty; } catch (Exception exception) { stat = exception.Message; } return(stat); }
public string InsertOrUpdate(ChartofAccountDTO chartofAccount) { try { var validate = Validate(chartofAccount); if (!string.IsNullOrEmpty(validate)) { return(validate); } if (ObjectExists(chartofAccount)) { return(GenericMessages.DatabaseErrorRecordAlreadyExists); } _chartofAccountRepository.InsertUpdate(chartofAccount); _unitOfWork.Commit(); return(string.Empty); } catch (Exception exception) { return(exception.Message); } }