示例#1
0
        public bool UndoDelete()
        {
            bool result = false;

            if (UndoDeleteCount == 0)
            {
                throw new InvalidOperationException("There are no items to be undeleted");
            }

            // Get the item to be undeleted
            MatrixTask matrixTask = _UndoDeleteStack.Pop();

            // Set the MatrixTaskId to 0 (like a new item)
            matrixTask.MatrixTaskId = 0;

            _Context.MatrixTasks.Add(matrixTask);

            try
            {
                this.SaveChanges();
                result = true;
            }
            catch (Exception)
            {
                throw;
            }

            return(result);
        }
示例#2
0
        /// <summary>
        /// Deletes a MatrixTask
        /// </summary>
        /// <returns>True if deleted, false if not</returns>
        public bool DeleteMatrixTask(int matrixTaskId)
        {
            bool       result     = false;
            MatrixTask matrixTask = this.GetMatrixTaskById(matrixTaskId);

            if (matrixTask != null)
            {
                // Push the item onto the Undo Stack
                _UndoDeleteStack.Push(matrixTask);
                _Context.MatrixTasks.Remove(matrixTask);
                result = true;
                _Context.SaveChanges();
            }
            return(result);
        }