public async Task <IHttpActionResult> GetDate()
        {
            IDefaultEntity entity = this.factory.Resolve <IDefaultEntity>();

            entity.Name = "name";
            entity.Id   = Guid.NewGuid();
            await this.repository.AddAsync(entity).ConfigureAwaitFalse();

            await Task.CompletedTask.ConfigureAwait(false);

            return(Ok(DateTime.Now));
        }
Beispiel #2
0
        public void Update(IDefaultEntity entity)
        {
            var type = entity.GetType();
            var id   = entity.GetId();

            if (repository.GetSingle(type, id) == null)
            {
                return;
            }

            repository.DeepUpdate(entity);
        }
Beispiel #3
0
        public void Add(IDefaultEntity entity)
        {
            var type = entity.GetType();
            var id   = entity.GetId();

            if (repository.GetSingle(type, id) != null)
            {
                return;
            }

            repository.Add(entity);
        }
Beispiel #4
0
        public int Insert(string tableName, IDefaultEntity entity, bool upsert = false, bool merge = true)
        {
            var insertPrimaryKey = entity.Id != default(int);

            var id = Insert(tableName, entity, insertPrimaryKey, upsert, merge);

            if (id != null)
            {
                entity.Id = (int)id;
            }

            return(entity.Id);
        }