Exemplo n.º 1
0
        public override void OnBeforeDelete(IDeleteRequestHandler handler)
        {
            if (ReferenceEquals(null, Target) ||
                (Target.Flags & FieldFlags.Updatable) != FieldFlags.Updatable)
            {
                return;
            }

            var idField = (handler.Row as IIdRow).IdField;
            var row     = new NoteRow();
            var fld     = NoteRow.Fields;

            var deleteList = new List <Int64>();

            new SqlQuery()
            .From(row)
            .Select(fld.NoteId)
            .Where(
                fld.EntityType == handler.Row.Table &
                fld.EntityId == idField[handler.Row].Value)
            .ForEach(handler.Connection, () =>
            {
                deleteList.Add(row.NoteId.Value);
            });

            foreach (var id in deleteList)
            {
                DeleteNote(handler.UnitOfWork, id);
            }
        }
Exemplo n.º 2
0
        private void SaveNote(IUnitOfWork uow, NoteRow note, string entityType, Int64 entityId, Int64?noteId)
        {
            note            = note.Clone();
            note.NoteId     = noteId;
            note.EntityType = entityType;
            note.EntityId   = entityId;
            note.InsertDate = null;
            note.ClearAssignment(NoteRow.Fields.InsertDate);

            var saveRequest = new SaveRequest <NoteRow> {
                Entity = note
            };

            if (noteId == null)
            {
                new NoteRepository().Create(uow, saveRequest);
            }
            else
            {
                new NoteRepository().Update(uow, saveRequest);
            }
        }