/// <summary>
 /// Erstellt ein neues MOVEMENT-Objekt.
 /// </summary>
 /// <param name="id">Anfangswert der Eigenschaft ID.</param>
 /// <param name="aMOUNT">Anfangswert der Eigenschaft AMOUNT.</param>
 /// <param name="dATE_ADDED">Anfangswert der Eigenschaft DATE_ADDED.</param>
 /// <param name="aCCOUNT_ID">Anfangswert der Eigenschaft ACCOUNT_ID.</param>
 /// <param name="cATEGORY_ID">Anfangswert der Eigenschaft CATEGORY_ID.</param>
 /// <param name="uSER_ID">Anfangswert der Eigenschaft USER_ID.</param>
 /// <param name="rEASON_ID">Anfangswert der Eigenschaft REASON_ID.</param>
 public static MOVEMENT CreateMOVEMENT(global::System.Guid id, global::System.Decimal aMOUNT, global::System.DateTime dATE_ADDED, global::System.Guid aCCOUNT_ID, global::System.Guid cATEGORY_ID, global::System.Guid uSER_ID, global::System.Guid rEASON_ID)
 {
     MOVEMENT mOVEMENT = new MOVEMENT();
     mOVEMENT.ID = id;
     mOVEMENT.AMOUNT = aMOUNT;
     mOVEMENT.DATE_ADDED = dATE_ADDED;
     mOVEMENT.ACCOUNT_ID = aCCOUNT_ID;
     mOVEMENT.CATEGORY_ID = cATEGORY_ID;
     mOVEMENT.USER_ID = uSER_ID;
     mOVEMENT.REASON_ID = rEASON_ID;
     return mOVEMENT;
 }
        public string AddMovement(string data)
        {
            try
            {
                var movement = JsonConvert.DeserializeObject<NewMovement>(data);
                var en = new HaushaltsrechnerEntities();

                var acc = en.ACCOUNT.FirstOrDefault(a=>a.ID == movement.AccountID);
                var cat = en.CATEGORY.FirstOrDefault(c=>c.ID == movement.CategoryID);
                var user = en.USER.FirstOrDefault(u => u.ID == SessionManager.CurrentUser.ID);
                var rea = en.REASON.Where(r => r.TEXT == movement.Reason);

                REASON reason;
                if (rea.Any())
                {
                    reason = rea.First();
                }
                else
                {
                    reason = new REASON
                    {
                        ID = Guid.NewGuid(),
                        TEXT = movement.Reason
                    };
                    en.REASON.AddObject(reason);
                }

                var m = new MOVEMENT
                {
                    ID = movement.ID,
                    DATE_ADDED = movement.DateAdded,
                    DATE_EDIT = DateTime.Now,
                    AMOUNT = Decimal.Parse(movement.Amount.Replace("€",string.Empty)),
                    MESSAGE = movement.Message,
                    USER = user,
                    ACCOUNT = acc,
                    CATEGORY = cat,
                    REASON = reason
                };

                en.MOVEMENT.AddObject(m);
                en.SaveChanges();
                return bool.TrueString;
            }
            catch
            {
                return bool.FalseString;
            }
        }
 /// <summary>
 /// Veraltete Methode zum Hinzufügen eines neuen Objekts zum EntitySet 'MOVEMENT'. Verwenden Sie stattdessen die Methode '.Add' der zugeordneten Eigenschaft 'ObjectSet&lt;T&gt;'.
 /// </summary>
 public void AddToMOVEMENT(MOVEMENT mOVEMENT)
 {
     base.AddObject("MOVEMENT", mOVEMENT);
 }