コード例 #1
0
        public async Task <Result> UpdateCommissionStatement(ScopeOptions scope, CommissionStatementEdit commissionStatement)
        {
            var validator = new CommissionStatementValidator(_context, scope, false);
            var result    = validator.Validate(commissionStatement).GetResult();

            if (!result.Success)
            {
                return(result);
            }

            var entity = await GetCommissionStatementEntityQuery(scope).FirstOrDefaultAsync(c => c.Id == commissionStatement.Id);

            if (entity == null)
            {
                return(new Result());
            }

            entity = MapModelToEntity(commissionStatement, entity);

            await _context.SaveChangesAsync();

            await _auditService.InsertAuditLog(scope, AuditLog.ACTION_UPDATE, "CommissionStatement", entity.Id, commissionStatement);

            return(result);
        }
コード例 #2
0
        public async Task <Result> InsertCommissionStatement(ScopeOptions scope, CommissionStatementEdit commissionStatement)
        {
            var validator = new CommissionStatementValidator(_context, scope, true);
            var result    = validator.Validate(commissionStatement).GetResult();

            if (!result.Success)
            {
                return(result);
            }

            var entity = MapModelToEntity(commissionStatement);

            entity.OrganisationId = scope.OrganisationId;
            await _context.CommissionStatement.AddAsync(entity);

            await _context.SaveChangesAsync();

            commissionStatement.Id = entity.Id;
            result.Tag             = commissionStatement;

            await _auditService.InsertAuditLog(scope, AuditLog.ACTION_INSERT, "CommissionStatement", entity.Id, commissionStatement);

            return(result);
        }