public virtual bool Create(ZOperationResult operationResult, TEntity entity) { try { if (UnitOfWork.BeforeCreate(operationResult, entity)) { if (BeforeCreate(operationResult, entity)) { object id = GetNextSequence(); if (id != null) { (entity as ZDataBase).SetId(new object[] { id }); } Set.Add(entity); if (AfterCreate(operationResult, entity)) { UnitOfWork.AfterCreate(operationResult, entity); } } } } catch (Exception exception) { operationResult.ParseExceptionEntityFramework(exception); } return(operationResult.Ok); }
public virtual bool Create(ZOperationResult operationResult, TEntity entity) { try { if (UnitOfWork.BeforeCreate(operationResult, entity)) { if (BeforeCreate(operationResult, entity)) { object id = GetNextSequence(); if (id != null) { (entity as ZDataBase).SetId(new object[] { id }); } string documentId = entity.GetType().Name.ToLower() + "/" + id.ToString(); DocumentSession.Store(entity, documentId); if (AfterCreate(operationResult, entity)) { UnitOfWork.AfterCreate(operationResult, entity); } } } } catch (Exception exception) { operationResult.ParseExceptionRavenDB(exception); } return(operationResult.Ok); }
public virtual bool Create(ZOperationResult operationResult, TEntity entity) { try { if (UnitOfWork.BeforeCreate(operationResult, entity)) { if (BeforeCreate(operationResult, entity)) { object id = GetNextSequence(); if (id != null) { (entity as ZDataBase).SetId(new object[] { id }); } if (DataDictionary.IsIdentity) { object identity = Connection.InsertWithIdentity <TEntity>(entity); (entity as ZDataBase).SetId(new object[] { identity }); } else { Connection.Insert <TEntity>(entity); } if (AfterCreate(operationResult, entity)) { UnitOfWork.AfterCreate(operationResult, entity); } } } } catch (Exception exception) { operationResult.ParseExceptionLINQ2DB(exception); } return(operationResult.Ok); }
public virtual bool Create(ZOperationResult operationResult, TEntityDTO entity) { try { if (UnitOfWork.BeforeCreate(operationResult, entity)) { if (BeforeCreate(operationResult, entity)) { Container.AddObject(EntitySetName, entity); if (AfterCreate(operationResult, entity)) { UnitOfWork.AfterCreate(operationResult, entity); } } } } catch (Exception exception) { operationResult.ParseExceptionOData(exception); } return(operationResult.Ok); }