private void ExecuteAddNewAccountCommand() { SelectedBankGuarantee = new BankGuaranteeDTO { WarehouseId = SelectedWarehouse.Id }; if (Banks != null) { var comercialBank = Banks.FirstOrDefault(b => b.DisplayName.ToLower().Contains("commercial")); SelectedBank = comercialBank ?? Banks.FirstOrDefault(); } AddNewAccountCommandVisibility = true; }
public string Validate(BankGuaranteeDTO bankGuarantee) { if (null == bankGuarantee) { return(GenericMessages.ObjectIsNull); } if (bankGuarantee.GuaranteedAmount == null || (bankGuarantee.GuaranteedAmount != null && bankGuarantee.GuaranteedAmount <= 0)) { return("Guaranteed Amount Can't be Empty/Zero"); } if (bankGuarantee.WarehouseId != 0 && new WarehouseService(true).Find(bankGuarantee.WarehouseId.ToString()) == null) { return("Warehouse is null/disabled "); } return(string.Empty); }
public string Disable(BankGuaranteeDTO bankGuarantee) { if (bankGuarantee == null) { return(GenericMessages.ObjectIsNull); } string stat; try { _bankGuaranteeRepository.Update(bankGuarantee); _unitOfWork.Commit(); stat = string.Empty; } catch (Exception exception) { stat = exception.Message; } return(stat); }
public bool ObjectExists(BankGuaranteeDTO bankGuarantee) { var objectExists = false; //var iDbContext = DbContextUtil.GetDbContextInstance(); //try //{ // var catRepository = new Repository<BankGuaranteeDTO>(iDbContext); // var catExists = catRepository // .Query() // .Filter(bp => bp.BankName == bankGuarantee.BankName && bp.AccountNumber == bankGuarantee.AccountNumber && bp.Id != bankGuarantee.Id) // .Get() // .FirstOrDefault(); // if (catExists != null) // objectExists = true; //} //finally //{ // iDbContext.Dispose(); //} return(objectExists); }
public string InsertOrUpdate(BankGuaranteeDTO bankGuarantee) { try { var validate = Validate(bankGuarantee); if (!string.IsNullOrEmpty(validate)) { return(validate); } if (ObjectExists(bankGuarantee)) { return(GenericMessages.DatabaseErrorRecordAlreadyExists); } _bankGuaranteeRepository.InsertUpdate(bankGuarantee); _unitOfWork.Commit(); return(string.Empty); } catch (Exception exception) { return(exception.Message); } }