Exemplo n.º 1
0
        public async Task <IFileIndexes> Update(IFileIndexes entity)
        {
            TFileIndexes tEntity = entity as TFileIndexes;

            var errors = await this.ValidateEntityToCheckExistsAtUpdate(tEntity);

            if (errors.Count() > 0)
            {
                await this.ThrowEntityException(errors);
            }

            try
            {
                this.StartTransaction();
                await base.Update(tEntity, x => new
                {
                    x.IndexName,
                    x.IndexType,
                    x.ListValue,
                    x.DefaultValue
                });

                this.CommitTransaction();
                return(tEntity);
            }
            catch (PostgresException ex)
            {
                throw new EntityUpdateException(ex);
            }
            catch
            {
                throw;
            }
        }
Exemplo n.º 2
0
        public async Task <IFileIndexes> AddNew(IFileIndexes entity)
        {
            TFileIndexes tEntity = entity as TFileIndexes;

            var errors = await this.ValidateEntityToCheckExists(tEntity);

            if (errors.Count() > 0)
            {
                await this.ThrowEntityException(errors);
            }

            try
            {
                this.StartTransaction();
                var savedEntity = await base.AddNew(entity as TFileIndexes);

                this.CommitTransaction();

                return(savedEntity);
            }
            catch (PostgresException ex)
            {
                throw new EntityUpdateException(ex);
            }
            catch
            {
                throw;
            }
        }