Exemplo n.º 1
0
        public void New(string CurrencyName, int currencyTypeID)
        {
            using (var ctx = new accountingEntities())
            {
                var newCur = new currency
                {
                    currencyTypeID = currencyTypeID,
                    name = CurrencyName
                };
                var result = ctx.currencies.FirstOrDefault(x => x.name.Equals(CurrencyName) &&  x.currencyTypeID.Equals(currencyTypeID));
                if (result != null)
                    throw new Exception("Currency Duplicated");
                else
                {
                    ctx.currencies.AddObject(newCur);
                    ctx.SaveChanges();

                }
            }
        }
 /// <summary>
 /// Deprecated Method for adding a new object to the currencies EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddTocurrencies(currency currency)
 {
     base.AddObject("currencies", currency);
 }
 /// <summary>
 /// Create a new currency object.
 /// </summary>
 /// <param name="id">Initial value of the ID property.</param>
 public static currency Createcurrency(global::System.Int32 id)
 {
     currency currency = new currency();
     currency.ID = id;
     return currency;
 }