Esempio n. 1
0
 /// <summary>
 /// Method for validating values and references in this EF-Object.
 /// Is called from Change-Tracking before changes will be saved for new unsaved entity-objects.
 /// </summary>
 /// <param name="user">The user.</param>
 /// <param name="context">Entity-Framework databasecontext</param>
 /// <returns>NULL if sucessful otherwise a Message-List</returns>
 public override IList <Msg> EntityCheckAdded(string user, IACEntityObjectContext context)
 {
     if (string.IsNullOrEmpty(InOrderNo))
     {
         List <Msg> messages = new List <Msg>();
         messages.Add(new Msg
         {
             Source       = GetACUrl(),
             ACIdentifier = "InOrderNo",
             Message      = "InOrderNo is null",
             //Message = Database.VarioBatch.Environment.TranslateMessage(this, "Error50000", "InOrderNo"),
             MessageLevel = eMsgLevel.Error
         });
         return(messages);
     }
     base.EntityCheckAdded(user, context);
     return(null);
 }
        /// <summary>
        /// Deletes this entity-object from the database
        /// </summary>
        /// <param name="database">Entity-Framework databasecontext</param>
        /// <param name="withCheck">If set to true, a validation happens before deleting this EF-object. If Validation fails message ís returned.</param>
        /// <param name="softDelete">If set to true a delete-Flag is set in the dabase-table instead of a physical deletion. If  a delete-Flag doesn't exit in the table the record will be deleted.</param>
        /// <returns>If a validation or deletion failed a message is returned. NULL if sucessful.</returns>
        public override MsgWithDetails DeleteACObject(IACEntityObjectContext database, bool withCheck, bool softDelete = false)
        {
            if (withCheck)
            {
                MsgWithDetails msg = IsEnabledDeleteACObject(database);
                if (msg != null)
                {
                    return(msg);
                }
            }
            int     sequence = Sequence;
            InOrder inOrder  = InOrder;

            if (inOrder.InOrderPos_InOrder.IsLoaded)
            {
                inOrder.InOrderPos_InOrder.Remove(this);
            }
            database.DeleteObject(this);
            InOrderPos.RenumberSequence(inOrder, sequence);
            return(null);
        }