/// <summary> /// Set the specified request. /// </summary> /// <param name="request">The request.</param> /// <returns>CurrencyResponse.</returns> public CurrencyResponse SetCurrencies(CurrencyRequest request) { var response = new CurrencyResponse(); var mapper = request.Currency; if (request.Action != PersistType.Delete) { if (!mapper.Validate()) { foreach (string error in mapper.ValidationErrors) { response.Message += error + Environment.NewLine; } response.Acknowledge = AcknowledgeType.Failure; return(response); } } try { if (request.Action == PersistType.Insert) { var currency = CurrencyDao.GetCurrenciesByCurrencyCode(mapper.CurrencyCode); if (currency != null) { response.Acknowledge = AcknowledgeType.Failure; response.Message = @"Mã tiền tệ " + mapper.CurrencyCode + @" đã tồn tại !"; return(response); } mapper.CurrencyId = CurrencyDao.InsertCurrency(mapper); response.Message = null; } else if (request.Action == PersistType.Update) { response.Message = CurrencyDao.UpdateCurrency(mapper); } else { var obj = CurrencyDao.GetCurrency(request.CurrencyId); response.Message = CurrencyDao.DeleteCurrency(obj); } } catch (Exception ex) { response.Acknowledge = AcknowledgeType.Failure; response.Message = ex.Message; return(response); } response.CurrencyId = mapper != null ? mapper.CurrencyId : 0; response.Acknowledge = response.Message != null ? AcknowledgeType.Failure : AcknowledgeType.Success; return(response); }
/// <summary> /// Deletes the account category. /// </summary> /// <param name="accountCategoryId">The account category identifier.</param> /// <returns>AccountCategoryResponse.</returns> public CurrencyResponse DeleteCurrency(string currencyId) { var response = new CurrencyResponse { Acknowledge = AcknowledgeType.Success }; try { var currencyEntity = ICurrencyDao.GetCurrency(currencyId); response.Message = ICurrencyDao.DeleteCurrency(currencyEntity); if (!string.IsNullOrEmpty(response.Message)) { if (response.Message.Contains("FK_BABankTransfer_Currency") || response.Message.Contains("FK_BADeposit_Currency") || response.Message.Contains("FK_BAWithDraw_Currency") || response.Message.Contains("FK_BUBudgetReserve_Currency") || response.Message.Contains("FK_BUPlanReceipt_CurrencyCode") || response.Message.Contains("FK_BUPlanWithdraw_Currency") || response.Message.Contains("FK_CAReceipt_Currency_CurrenyID") || response.Message.Contains("FK_GLVoucher_Currency_CurrencyCode")) { response.Message = @"Bạn không thể xóa mã tiền tệ " + currencyEntity.CurrencyCode + " vì đã có phát sinh trong chứng từ hoặc danh mục liên quan!"; } response.Acknowledge = AcknowledgeType.Failure; return(response); } response.CurrencyId = currencyEntity.CurrencyId; return(response); } catch (Exception ex) { response.Acknowledge = AcknowledgeType.Failure; response.Message = ex.Message; return(response); } }
/// <summary> /// Removes specific Currency /// </summary> /// <param name="id">Identifier</param> /// <returns>No of Currency Deleted</returns> public int Delete(int id = 0) { return(CurrencyDao.DeleteCurrency(id)); }
public virtual void DeleteCurrency(String code) { entityDao.DeleteCurrency(code); }