Beispiel #1
0
 //create
 public int PreserveAttachment(PreserveAttachmentModel model)
 {
     if (!_authorization.Create(new AttachmentKeyModel {
         EntityName = model.EntityName, FieldName = model.FieldName, EntityId = model.EntityId
     }))
     {
         throw new UnauthorizedAccessException();
     }
     return(_business.PreserveAttachment(model));
 }
        public int PreserveAttachment(PreserveAttachmentModel model)
        {
            var attachment = _DbContext.Attachments
                             .SingleOrDefault(x => x.EntityName == model.EntityName &&
                                              x.FieldName == model.FieldName &&
                                              x.EntityId == model.EntityId);

            if (attachment == null)
            {
                throw new NullReferenceException();
            }
            attachment.EntityId = model.EntityId;
            _DbContext.SaveChanges();
            return(attachment.Id);
        }