Beispiel #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 == Convert.ToInt64(idField.AsObject(handler.Row)))
            .ForEach(handler.Connection, () =>
            {
                deleteList.Add(row.NoteId.Value);
            });

            foreach (var id in deleteList)
            {
                DeleteNote(handler.UnitOfWork, id);
            }
        }
Beispiel #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(Context).Create(uow, saveRequest);
            }
            else
            {
                new NoteRepository(Context).Update(uow, saveRequest);
            }
        }