public async Task <Result> InsertCommissionType(CommissionType model)
        {
            var validator = new CommissionTypeValidator(_context, true);
            var result    = validator.Validate(model).GetResult();

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

            var entity = MapCommissionTypeModelToEntity(model);
            await _context.CommissionType.AddAsync(entity);

            await _context.SaveChangesAsync();

            model.Id   = entity.Id;
            result.Tag = model;

            return(result);
        }
        public async Task <Result> UpdateCommissionType(CommissionType model)
        {
            var validator = new CommissionTypeValidator(_context, false);
            var result    = validator.Validate(model).GetResult();

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

            var entity = await _context.CommissionType.FindAsync(model.Id);

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

            entity = MapCommissionTypeModelToEntity(model, entity);
            await _context.SaveChangesAsync();

            return(result);
        }